Lines & Graphs

Horizontal and Vertical Lines

A horizontal line has the equation y=cy = c and a slope of 00. A vertical line has the equation x=cx = c and an undefined slope.

y=candx=cy = c \quad \text{and} \quad x = c

The constant cc is the one coordinate that never changes along the line. Everything else about these lines, from graphs to function tests to the places where familiar formulas break, follows from that single fact.

What Is the Equation of a Horizontal or Vertical Line?

Read y=3y = 3 as a rule: the height is 33, whatever xx you choose. The points (−4,3)(-4, 3), (0,3)(0, 3) and (9,3)(9, 3) all obey it, and together they form a flat line. The variable that is missing from the equation is free to take any value. That is the whole idea.

The trap that costs the most points is thinking the equation names the direction. It does not. The equation y=3y = 3 gives the place where the line crosses the yy-axis, and the line runs parallel to the xx-axis. A quick mental check: the line is parallel to the axis of the variable that is missing from the equation. In x=5x = 5 the yy is missing, so the line is parallel to the yy-axis, which means vertical.

This also pins down the axes themselves. The xx-axis is the horizontal line y=0y = 0, and the yy-axis is the vertical line x=0x = 0. If you are shaky on how coordinates are read, plotting points on the coordinate plane is worth a quick pass first.

Horizontal line Vertical line
Equation y=cy = c x=cx = c
Slope 00 undefined
Parallel to xx-axis yy-axis
Function of xx? yes no

Quick check

What is the equation of the yy-axis?

Why Horizontal Lines Have Slope 0 and Vertical Lines Do Not

Take two points on a horizontal line, (x1,c)(x_1, c) and (x2,c)(x_2, c). Their heights are identical, so the rise is 00:

m=c−cx2−x1=0x2−x1=0m = \frac{c - c}{x_2 - x_1} = \frac{0}{x_2 - x_1} = 0

Now take two points on a vertical line, (c,y1)(c, y_1) and (c,y2)(c, y_2). This time the run is the part that vanishes:

m=y2−y1c−c=y2−y10m = \frac{y_2 - y_1}{c - c} = \frac{y_2 - y_1}{0}

Why “undefined” and not “infinite” or “zero”? Division is the reverse of multiplication. Saying 40=m\frac{4}{0} = m would require 0⋅m=40 \cdot m = 4, and no number does that. There is also a visual reason: tilt a line toward vertical from one side and its slope grows toward positive infinity, tilt it from the other side and the slope heads toward negative infinity. With no single value to settle on, the slope is left undefined. Using the slope formula on any two points of a vertical line always ends with a zero in the denominator, which is itself a quick test for “vertical”.

The same reason explains why a vertical line cannot be written in slope-intercept form. The form y=mx+by = mx + b needs a slope, and a vertical line has none to offer. A horizontal line fits perfectly with m=0m = 0, since y=0x+cy = 0x + c simplifies to y=cy = c. Students often mix up “zero slope” and “no slope”. Zero slope is flat and perfectly fine. No slope (undefined) is a wall.

How Do You Graph Horizontal and Vertical Lines?

Graphing needs no table and no slope. Use these steps:

  1. Find the variable in the equation. If it is yy, the line is horizontal. If it is xx, the line is vertical.
  2. Mark that value on the matching axis. For y=−4y = -4, find −4-4 on the yy-axis. For x=2x = 2, find 22 on the xx-axis.
  3. Draw a line through that mark, parallel to the other axis, with arrows on both ends.
  4. Spot-check by reading off two points and confirming the fixed coordinate.

Negatives behave as you would expect: y=−4y = -4 lies four units below the xx-axis, and x=−3x = -3 lies three units left of the yy-axis. The common slip is swapping the two, drawing x=−3x = -3 as a flat line because the −3-3 feels like a height. Whenever you hesitate, write one point from the line. For x=−3x = -3, a point is (−3,0)(-3, 0), which sits on the xx-axis, so the line must stand upright there.

Intercepts of these lines

A horizontal line y=cy = c with c≠0c \neq 0 never touches the xx-axis, so it has no xx-intercept. A vertical line x=cx = c with c≠0c \neq 0 has no yy-intercept. See finding x and y intercepts for the usual method and why it needs this exception.

Try this: Sketch x=−4x = -4 and y=2y = 2 on one grid. Then list three points on each line and circle the coordinate that stayed the same in every point.

How Do You Write the Equation of a Line Through Two Points?

For ordinary lines, the equation of a line through two points starts with the slope. For these special lines, a faster method is to compare coordinates first. If the yy-values match, the line is y=y = that value. If the xx-values match, the line is x=x = that value. Only when neither pair matches do you need the full slope calculation.

Example 1. Find the line through (4,−1)(4, -1) and (4,6)(4, 6).

The xx-values match, so the line is vertical. To confirm:

m=6−(−1)4−4=70m = \frac{6 - (-1)}{4 - 4} = \frac{7}{0}

The slope is undefined, and the equation is x=4x = 4. Check by substituting: both points have x=4x = 4, so both satisfy the equation.

Example 2. Find the line through (−2,3)(-2, 3) and (5,3)(5, 3).

The yy-values match. Confirming with the slope:

m=3−35−(−2)=07=0m = \frac{3 - 3}{5 - (-2)} = \frac{0}{7} = 0

Now apply point-slope form with the point (−2,3)(-2, 3):

y−3=0(x+2)⇒y=3y - 3 = 0(x + 2) \quad\Rightarrow\quad y = 3

Notice that point-slope form works for horizontal lines but breaks for vertical ones, because there is no slope to substitute. That is why vertical lines always need to be handled by inspection.

Are Horizontal and Vertical Lines Functions?

A horizontal line y=cy = c is a function. Every input xx produces exactly one output, cc. It is called a constant function. Its domain is all real numbers, and its range is the single value {c}\{c\}.

A vertical line x=cx = c is not a function of xx. The single input cc is paired with every real number as an output. Its domain is only {c}\{c\}, and its range is all real numbers. This is exactly what the vertical line test detects: a vertical line drawn through a graph should never hit it twice, and the graph of x=cx = c is itself a vertical line that hits itself everywhere.

Swap the roles

The relation x=cx = c is not a function of xx, but it is a function if you treat yy as the input and xx as the output. Whether something is a function depends on which variable you call the input.

Quick check

Does the graph of x=5x = 5 represent yy as a function of xx? Answer yes or no.

Horizontal and Vertical Lines in Standard Form and Inequalities

In standard form, Ax+By=CAx + By = C, these lines are the cases where one coefficient is zero. If A=0A = 0 the xx term vanishes and the line is horizontal. If B=0B = 0 the yy term vanishes and the line is vertical. So the standard form hides a clue: a missing variable always means a line parallel to an axis.

Example 3. Identify and graph 2y+10=02y + 10 = 0 and 3x=−93x = -9.

For the first, subtract 1010 and divide by 22:

2y=−10⇒y=−52y = -10 \quad\Rightarrow\quad y = -5

This is a horizontal line five units below the xx-axis. For the second, divide by 33:

x=−3x = -3

This is a vertical line three units left of the yy-axis.

The same ideas carry over to graphing linear inequalities. For x>2x > 2, draw a dashed vertical line at x=2x = 2 and shade to the right, where xx is larger. For y≤−1y \le -1, draw a solid horizontal line at y=−1y = -1 and shade below. The rule that prevents mistakes: inequalities in xx shade left or right, and inequalities in yy shade up or down.

Are Horizontal and Vertical Lines Parallel or Perpendicular?

Any two horizontal lines are parallel, and so are any two vertical lines. Any horizontal line is perpendicular to any vertical line. The familiar rule from slopes of parallel and perpendicular lines says perpendicular slopes multiply to −1-1, but that rule cannot be applied here, since a vertical line has no slope to multiply. Treat horizontal and vertical lines as the exception, decided by sight rather than by slope.

This makes intersections almost free. The lines x=ax = a and y=by = b meet at exactly (a,b)(a, b), with no equations to solve. Distances become simple too. The distance between parallel lines y=b1y = b_1 and y=b2y = b_2 is ∣b1−b2∣|b_1 - b_2|, and the distance formula collapses to that same absolute difference whenever two points share a coordinate.

Example 4. Find the perimeter of the rectangle bounded by x=1x = 1, x=7x = 7, y=−2y = -2 and y=3y = 3.

The width is ∣7−1∣=6|7 - 1| = 6. The height is ∣3−(−2)∣=5|3 - (-2)| = 5. The perimeter is:

2(6+5)=222(6 + 5) = 22

Subtracting the negative is where most errors appear: 3−(−2)=53 - (-2) = 5, not 11.

Quick check

What is the distance between the parallel lines y=−2y = -2 and y=6y = 6?

Where Do Horizontal and Vertical Lines Appear in Real Life?

On a graph of distance against time, a horizontal segment means standing still: the position does not change while the clock runs. This matches the idea of average rate of change, where a horizontal line is a rate of exactly zero. A speed-against-time graph shows a horizontal line for cruise control. A vertical segment on a time graph would mean being in two places at one instant, which is why real motion never produces one.

Vertical lines are useful the other way around. In data charts, a vertical line x=cx = c often marks an event, such as a policy change or a product launch, while a horizontal line y=cy = c marks a target, an average or a threshold. City grids work the same way: streets running east to west are horizontal lines, and avenues running north to south are vertical lines, so an address is really an intersection (a,b)(a, b).

One practical catch: graphing calculators and many spreadsheet tools expect yy as a function of xx, so typing x=3x = 3 often fails. Use the tool’s vertical line feature, or enter a very steep line such as y=10000(x−3)y = 10000(x - 3) as a rough stand-in. The reason is the same one from earlier: a vertical line is not a function.

Practice problems

0 of 5 solved

  1. Write the equation of the horizontal line through (−3,5)(-3, 5).

  2. Find the slope and the equation of the line through (4,−1)(4, -1) and (4,6)(4, 6).

  3. Rewrite 3y+12=03y + 12 = 0 as a simple line equation and state its slope.

  4. Where do the lines x=−2x = -2 and 2y−7=32y - 7 = 3 intersect?

  5. The lines x=−2x = -2, y=1y = 1 and y=x+6y = x + 6 form a triangle. Find its area.

Common questions

What is the slope of a horizontal line?

The slope of a horizontal line is 00. Every point has the same yy-value, so the rise between any two points is 00, and 00 divided by a nonzero run is 00.

Why is the slope of a vertical line undefined?

Every point on a vertical line has the same xx-value, so the run is 00. Slope is rise divided by run, and dividing by 00 has no meaning, so the slope is called undefined.

Is a vertical line a function?

No. A vertical line x=cx = c pairs one input with infinitely many outputs, so it fails the vertical line test. A horizontal line y=cy = c is a function, called a constant function.

How do you write the equation of a horizontal line through a point?

Take the yy-coordinate of the point and set yy equal to it. For (7,−3)(7, -3) the horizontal line is y=−3y = -3. For the vertical line through the same point, use the xx-coordinate: x=7x = 7.

Are horizontal and vertical lines perpendicular?

Yes. Every horizontal line meets every vertical line at a right angle. The negative reciprocal rule cannot show it, because a vertical slope is undefined, but the axes themselves are the standard example.

Do horizontal and vertical lines have intercepts?

A horizontal line y=cy = c with c≠0c \neq 0 has a yy-intercept at (0,c)(0, c) and no xx-intercept. A vertical line x=cx = c with c≠0c \neq 0 has an xx-intercept at (c,0)(c, 0) and no yy-intercept.

Up next