Part 9 of 10 · LinesSee the whole course

Slope of horizontal and vertical lines

Short answer

A horizontal line has slope 0 and an equation like y = 3. A vertical line has undefined slope, because you would have to divide by 0, and an equation like x = 2.

Flat lines: slope 0

On a flat line, you go across but never up or down. The rise is 0, so the slope is rise ÷ run = 0 ÷ run = 0.

Every point on a flat line has the same height, so the equation is just that height: y = c.

Points (1, 3) and (5, 3)
Rise: 3 − 3 = 0
Run: 5 − 1 = 4
Slope: 0 ÷ 4 = 0, and the line is y = 3

Upright lines: undefined slope

On an upright line, you go up but never across. The run is 0, and the slope is rise ÷ 0. Dividing by 0 is not possible, so the slope is undefined. It is not 0, and it is not “infinity” either.

Every point on an upright line has the same x, so the equation is that x: x = c.

Points (2, 1) and (2, 7)
Rise: 7 − 1 = 6
Run: 2 − 2 = 0
Slope: 6 ÷ 0 = undefined, and the line is x = 2

See it happen

Point A is fixed. Point B is A plus a run across and a rise up. Slide the run down towards 0: the slope gets bigger and bigger, and at 0 it breaks. Then set the rise to 0 and see the flat line.

slope = 4 ÷ 2 = 2
Slide the run down to 0 and watch what happens to the slope.

How to remember which is which

And for the equations: y = 3 says “y is always 3”, so the height never changes and the line is flat. x = 3 says “x is always 3”, so the line is upright through 3 on the x-axis.

A vertical line is not a function

On the line x = 2, the single input 2 goes with every output at once. That is the opposite of a function, which gives exactly one output for each input. It fails the vertical line test from our post on what a function is. A horizontal line, on the other hand, is a perfectly good function: every input gives the same output.

Watch it explained in under a minute

The same idea, narrated step by step. Square version for sharing: download the 1:1 video.

The five mistakes to avoid

Try it yourself

Tap a question to see the answer.

1. Find the slope and the equation of the line through (1, 3) and (5, 3)

Rise 0, run 4: slope 0 ÷ 4 = 0. The line is flat: y = 3.

2. Find the slope and the equation of the line through (2, 1) and (2, 7)

Run 0, so the slope is undefined. The line is upright: x = 2.

3. Which one is the vertical line: y = 4 or x = 4?

x = 4. In x = 4 the x-value is always 4, so the line is upright through 4 on the x-axis.

Where this fits in

These are the two cases that do not fit y = mx + b, so keep them in mind next to slope-intercept form and finding the equation from two points. Next in this course, we use lines to solve something new: how to solve a linear equation.

Quick answers

Questions about this topic

What is the slope of a horizontal line?

The slope of a horizontal line is 0. A flat line has a rise of 0, and 0 divided by any run is 0.

What is the slope of a vertical line?

The slope of a vertical line is undefined. It has a run of 0, and you cannot divide by 0, so there is no slope to find.

Why is the slope of a vertical line undefined?

Slope is rise ÷ run, and a vertical line has a run of 0. Dividing by 0 has no answer, so we say the slope is undefined.

Is a vertical line a function?

No. A vertical line such as x = 2 puts many outputs with the single input 2, so it fails the vertical line test. A horizontal line is a function.

Keep going

Learn it by playing

Pip: Math Adventure is a math game for iPhone where functions, lines, equations and calculus are puzzles you solve by playing. It is coming soon to the App Store.

Join the list and we will tell you the day Pip is out.