Horizontal and Vertical Lines

A horizontal line goes straight across, and its equation is y = b, where b is the y-value of every point on it. A vertical line goes straight up and down, and its equation is x = a. Horizontal lines have a slope of 0. Vertical lines have an undefined slope.

Before this lesson: You should know how to plot points on the coordinate plane and how to find slope from two points.

What Are Horizontal and Vertical Lines?

A horizontal line is flat, like the horizon. Look at these points: (−3, 2), (0, 2) and (4, 2). The x-values change, but every y-value is 2. So the line through them is y = 2.

A vertical line stands straight up, like a flagpole. Look at these points: (1, −2), (1, 0) and (1, 5). The y-values change, but every x-value is 1. So the line through them is x = 1.

The horizontal line y = 3 and the vertical line x = −2 on a coordinate grid. They cross at the point (−2, 3).
The line y = 3 goes across. The line x = −2 goes up and down. They cross at (−2, 3).

Here is a simple way to remember it. The equation tells you which value stays the same.

  • y = 3 means “y is always 3.” The x-values can be anything, so the line goes sideways.
  • x = -2 means “x is always −2.” The y-values can be anything, so the line goes up and down.

Equations of Horizontal and Vertical Lines

LineEquationSlopeWhere it crosses an axis
Horizontaly = b0Crosses the y-axis at (0, b)
Verticalx = aUndefinedCrosses the x-axis at (a, 0)

Two special lines are worth knowing:

  • The x-axis is the horizontal line y = 0.
  • The y-axis is the vertical line x = 0.

Why Their Slopes Are 0 and Undefined

Use the slope formula on two points from each line.

For the horizontal line through (−3, 2) and (4, 2):

m = \frac{2 - 2}{4 - (-3)} = \frac{0}{7} = 0

The rise is 0, so the slope is 0.

For the vertical line through (1, −2) and (1, 5):

m = \frac{5 - (-2)}{1 - 1} = \frac{7}{0}

The run is 0, and you can’t divide by 0. So the slope of a vertical line is undefined.

Worked Examples

Example 1: Horizontal line through a point

Write the equation of the horizontal line through (4, −5).

Step 1. On a horizontal line, every point has the same y-value.

Step 2. Read the y-value of the point (4, −5). It is −5.

y = -5

Step 3. Write the equation. Every point on the line has y equal to −5.

Answer: y = -5

Example 2: Vertical line through a point

Write the equation of the vertical line through (−3, 6).

Step 1. On a vertical line, every point has the same x-value.

Step 2. Read the x-value of the point (−3, 6). It is −3.

x = -3

Step 3. Write the equation. Every point on the line has x equal to −3.

Answer: x = -3

Example 3: Line through two points

Write the equation of the line through (2, 7) and (2, −1). What is its slope?

Step 1. Compare the points. Both x-values are 2, but the y-values are different.

x = 2

Step 2. When the x-values match, the line is vertical. Write the equation with that x-value.

m = \frac{-1 - 7}{2 - 2}

Step 3. Find the slope with the slope formula.

m = \frac{-8}{0}

Step 4. Subtract on the top and on the bottom.

Step 5. The bottom is 0, and you can’t divide by 0.

Answer: x = 2. The slope is undefined.

Example 4: Where two lines cross

Graph y = -2 and x = 4. Where do they cross?

The horizontal line y = −2 and the vertical line x = 4 cross at the point (4, −2).
The lines y = −2 and x = 4 cross at the point (4, −2).

Step 1. Draw y = -2 as a flat line through −2 on the y-axis.

Step 2. Draw x = 4 as an up-and-down line through 4 on the x-axis.

Step 3. Take the x-value from x = 4. Every point on that line has x = 4.

Step 4. Take the y-value from y = -2. Every point on that line has y = −2.

(4, -2)

Step 5. Put them together as an ordered pair.

Answer: They cross at (4, −2).

Example 5: Word problem

A parking garage charges $12 to park for any amount of time up to 8 hours. Write an equation for the cost C after h hours. What is the slope, and what does it mean?

Step 1. The cost is $12 no matter how many hours you park. So C is always 12.

C = 12

Step 2. Write the equation.

m = \frac{12 - 12}{8 - 0}

Step 3. Pick two points on the graph, such as (0, 12) and (8, 12). Put them into the slope formula.

m = \frac{0}{8}

Step 4. Subtract on the top and on the bottom.

m = 0

Step 5. Divide. Zero divided by any other number is 0.

Answer: C = 12, for up to 8 hours. The graph is a horizontal line, so the slope is 0. The cost goes up by $0 for each extra hour.

Common Mistakes

MistakeWhat it looks likeHow to fix it
Using the wrong valueHorizontal line through (2, 5) written as x = 2A horizontal line keeps y the same: y = 5.
Mixing up the slopes“The slope of x = 3 is 0.”Vertical lines have undefined slope. Horizontal lines have slope 0.
Graphing in the wrong directionDrawing y = 4 up and down through 4 on the x-axisy = 4 crosses the y-axis at 4 and goes across.
Thinking it’s one point“x = 3 is the point (3, 0).”x = 3 is a whole line of points like (3, 0), (3, 1) and (3, −8).

Horizontal and Vertical Lines in Slope-Intercept Form

A horizontal line fits the form y = mx + b with a slope of 0. For example, y = 0x + 4 is the same as y = 4.

A vertical line does not fit that form. It has no slope to put in for m, so you always write it as x = a. You’ll use this form in the next lesson, Slope-Intercept Form.

A horizontal line and a vertical line always meet at a right angle, so they are perpendicular.

Practice Problems

Write each equation, or answer the question.

  1. The horizontal line through (3, 8)
  2. The vertical line through (−6, 1)
  3. The line through (−4, 9) and (5, 9). What is its slope?
  4. The line through (0, −3) and (0, 7). What is its slope?
  5. What is the slope of y = -7?
  6. Is x = -1 horizontal or vertical?
  7. Where do y = 6 and x = -2 cross?
  8. The line through (7, −4) that is parallel to the y-axis
  9. The line through (−5, 2) that is parallel to the x-axis
  10. A hot-air balloon floats at a steady height of 300 feet for 10 minutes. Write an equation for its height h after t minutes. What is the slope?
Show answers

1.

A horizontal line keeps the same y-value

y = 8

The y-value of (3, 8) is 8.

2.

A vertical line keeps the same x-value

x = -6

The x-value of (−6, 1) is −6.

3.

y = 9

Both y-values are 9, so the line is horizontal.

m = \frac{9 - 9}{5 - (-4)} = \frac{0}{9} = 0

Find the slope.

4.

x = 0

Both x-values are 0, so the line is vertical. It is the y-axis.

m = \frac{7 - (-3)}{0 - 0} = \frac{10}{0}

Find the slope.

You can’t divide by 0
The slope is undefined.

5.

y = -7 has the same y-value at every point, so it is a horizontal line

m = 0

A horizontal line has slope 0.

6.

x is always −1, and y can be anything
It is a vertical line.

7.

Take the x-value from x = -2
Take the y-value from y = 6

(-2, 6)

Write the ordered pair.

They cross at (−2, 6).

8.

A line parallel to the y-axis is vertical, so it keeps the same x-value

x = 7

The x-value of (7, −4) is 7.

9.

A line parallel to the x-axis is horizontal, so it keeps the same y-value

y = 2

The y-value of (−5, 2) is 2.

10.

h = 300 \text{ for } 0 \le t \le 10

The height stays 300 feet the whole time.

m = \frac{300 - 300}{10 - 0} = \frac{0}{10} = 0

Use the points (0, 300) and (10, 300) to find the slope.

The slope is 0 feet per minute, because the height doesn’t change.

Want more practice? The Algebra 1 Unit 4 Practice Pack (Part 1) has 39 pages of problems on this and the other lessons in the unit. Every answer is worked step by step, and the steps link to the lessons that teach them. A cheat sheet is included.

Horizontal and Vertical Lines FAQ

Is y = 5 a horizontal or vertical line?

The line y = 5 is horizontal. Every point on it has a y-value of 5, so it runs straight across.

What is the slope of a vertical line?

The slope of a vertical line is undefined. The run between any two points is 0, and you can’t divide by 0.

What is the equation of the x-axis?

The x-axis is the line y = 0, and the y-axis is the line x = 0.

Are horizontal and vertical lines perpendicular?

Yes. A horizontal line and a vertical line always cross at a right angle.

Summary

  • A horizontal line has the equation y = b and a slope of 0.
  • A vertical line has the equation x = a and an undefined slope.
  • The equation names the value that stays the same: y for horizontal lines, x for vertical lines.
  • The x-axis is y = 0, and the y-axis is x = 0.
  • A horizontal line and a vertical line cross at (a, b).

Previous lesson: Slope

Next lesson: Slope-Intercept Form

Back to the Algebra 1 Index