Horizontal Line: Definition Equation Slope & Examples

#Horizontal Line
TL;DR
A horizontal line runs flat from left to right; its equation is y=ky = k and its slope is 00. Six worked examples show why, how it differs from a vertical line, and how it tests functions.
Prabhjot KaurΒ·reviewed byShikha SharmaLast updated on December 2, 202613 min read

Key Points

  • A horizontal line keeps the same y-coordinate at every point, so on a graph it is parallel to the x-axis.
  • Its equation is y=ky = k, where kk is the height. There is no xx in it.
  • Its slope is 00, a real number. The vertical line is the one with an undefined slope.
  • The horizontal line test uses these lines to check whether a function is one-to-one.

The Flattest Line on the Graph, and Why That Matters

Lay a spirit level on a shelf: when the bubble sits dead centre, the shelf is level.

  • Draw that shelf side-on on a grid and you get a horizontal line: it never climbs and never dips, however far it runs.
  • That flatness decides everything else. It fixes the equation, forces the slope to be 00, and turns the line into a tool for testing functions.
  • See why a flat line behaves this way, and the equation and slope stop being facts to memorise.
a horizontal line is level, with every point at the same height
The horizontal line y = 2 with the points (βˆ’5, 2), (βˆ’1, 2) and (4, 2) marked, and a yellow spirit level resting on it with its bubble centred.

What Is a Horizontal Line?

A horizontal line is a straight line on which every point has the same y-coordinate.

  • Moving along it changes your left-right position (the x-coordinate) but never your height (the y-coordinate).
  • On a coordinate plane, "horizontal" means parallel to the x-axis. The x-axis itself is the horizontal line at height 00.
  • In the real world, horizontal means level: at right angles to a hanging plumb line.
  • The name comes from horizon, the flat line where land seems to meet sky.

The Equation of a Horizontal Line

Because the height never changes, the equation names that height and nothing else:

y=ky = k
  • kk is a constant: the height of the line. The line y=2y = 2 holds (βˆ’5,2)(-5, 2), (βˆ’1,2)(-1, 2), (4,2)(4, 2) and every other point at height 2.
  • There is no xx, because xx is free: any x-value will do.
  • To write the equation you need one thing, the y-coordinate of any point. Through (7,βˆ’3)(7, -3), it is y=βˆ’3y = -3.
  • It crosses the y-axis at (0,k)(0, k) and never meets the x-axis, unless k=0k = 0.

Our page on the equation of a line parallel to the x-axis derives the same equation from the general form of a line.

The Slope of a Horizontal Line

The slope of a line measures how much it rises for each step across, and a horizontal line never rises, so its slope is 00.

Way 1: rise over run

Take any two points on the line, (x1,k)(x_1, k) and (x2,k)(x_2, k):

m=y2βˆ’y1x2βˆ’x1=kβˆ’kx2βˆ’x1=0x2βˆ’x1=0m = \frac{y_2 - y_1}{x_2 - x_1} = \frac{k - k}{x_2 - x_1} = \frac{0}{x_2 - x_1} = 0
  • The rise is always 00, and the run is never 00 because the points are different.

Way 2: the angle with the x-axis

  • Slope equals tan⁑θ\tan\theta, where ΞΈ\theta is the angle with the positive x-axis.
  • As a line flattens, tan⁑45Β°=1\tan 45Β° = 1, then tan⁑20Β°β‰ˆ0.36\tan 20Β° \approx 0.36, then tan⁑0Β°=0\tan 0Β° = 0.
the slope of a line shrinks to zero as its angle with the x-axis shrinks to zero
Three lines from one point: at 45 degrees with slope tan 45Β° = 1.00, at 20 degrees with slope tan 20Β° = 0.36, and flat at 0 degrees with slope tan 0Β° = 0.

Zero is a slope; undefined is not

This is the most confused point on the topic.

  • 05=0\frac{0}{5} = 0, because 0Γ—5=00 \times 5 = 0: the division has an answer.
  • 50\frac{5}{0} has no answer, because no number times 00 gives 55.
  • A horizontal line divides zero by something: slope 00. A vertical line divides something by zero: its slope is undefined.
a horizontal line has slope zero while a vertical line has an undefined slope
Two panels. Left: a horizontal line through (βˆ’2, 1) and (3, 1), rise 0 divided by run 5 equals 0. Right: a vertical line through (1, βˆ’2) and (1, 3), rise 5 divided by run 0, which is undefined.
  • So "zero slope" (flat) and "no slope" (upright) mean opposite things.

Try It Yourself

Try it yourself: drag both blue handles to the same height, such as (βˆ’4,2)(-4, 2) and (4,2)(4, 2), and the slope reads 00. Drag both orange handles to the same x and the slope reads "undefined". Nudge one blue handle up and the flat line tilts.

How to Draw a Horizontal Line

Drawing one is quick, because it depends only on the height kk.

  1. Find kk from the equation y=ky = k, or from the y-coordinate of a given point.
  2. Mark (0,k)(0, k) on the y-axis.
  3. Mark one more point at the same height, such as (4,k)(4, k).
  4. Join them with a ruler and extend the line both ways. Every point you pass shares the y-coordinate kk.

A Horizontal Line Is a Constant Function

Read y=3y = 3 as a function, f(x)=3f(x) = 3: whatever you feed in, the output is 33.

  • That makes it a constant function, and its graph is the horizontal line at height 3.
  • Domain: every real number. Range: just {3}\{3\}.
  • Each x gives one output, so every vertical line meets it once: it passes the vertical line test.
  • Its rate of change is 00, which is the slope again in other words.
a horizontal line is the graph of a constant function and passes the vertical line test
The graph of the constant function f(x) = 3 as a horizontal line, crossed once each by three dashed vertical lines at x = βˆ’4, 0.5 and 5; the domain is every real x and the range is {3}.

The Horizontal Line Test

The same flatness gives a horizontal line a second job: checking whether a function is one-to-one, meaning different inputs always give different outputs.

  • The test: if any horizontal line meets the graph more than once, two inputs share an output, so the function is not one-to-one.
  • y=x2y = x^2 fails: the line y=4y = 4 meets it at (βˆ’2,4)(-2, 4) and (2,4)(2, 4).
  • y=x3y = x^3 passes: y=4y = 4 meets it only at x=43β‰ˆ1.59x = \sqrt[3]{4} \approx 1.59.
  • Any slanted straight line, like y=2x+1y = 2x + 1, passes, because each height is reached once.
the horizontal line test shows y = xΒ² is not one-to-one and y = xΒ³ is one-to-one
Two panels. Left: the parabola y = xΒ² cut by the dashed line y = 4 at (βˆ’2, 4) and (2, 4), so it fails the test. Right: the curve y = xΒ³ cut by y = 4 at a single point near (1.59, 4), so it passes.
  • Only a one-to-one function can be run backwards, so this test decides whether a function has an inverse.
  • Keep the two tests apart: the vertical test asks "is it a function?", the horizontal test asks "is it one-to-one?"

Horizontal Line vs Vertical Line

A horizontal line is easiest to pin down beside its opposite.

Horizontal line Vertical line
Direction left to right up and down
Equation y=ky = k x=hx = h
Slope 00 undefined
Parallel to the x-axis the y-axis
Crosses the y-axis at (0,k)(0, k) the x-axis at (h,0)(h, 0)
A function? yes, a constant function no
  • The missing letter names the direction: no xx means horizontal, no yy means vertical.
  • The two always meet at a right angle, at (h,k)(h, k).
  • The "slopes multiply to βˆ’1-1" test for perpendicular lines cannot confirm this pair, because the vertical line has no slope to multiply.

Examples of the Horizontal Line

These build from naming a line to using it to measure a shape.

Example 1

Describe the line y=4y = 4: its direction, slope and intercepts.

  1. It is horizontal, at height 4, so its slope is 00.
  2. It crosses the y-axis at (0,4)(0, 4) and never meets the x-axis.

Final answer: horizontal, slope 0, y-intercept (0,4)(0, 4), no x-intercept.

Example 2

Find the slope of the line through (4,7)(4, 7) and (9,7)(9, 7).

  1. The working gives 7βˆ’79βˆ’4=05\frac{7 - 7}{9 - 4} = \frac{0}{5}. The zero on top looks like trouble, and it is tempting to write "undefined".
  2. Check that: 05\frac{0}{5} asks what number times 5 gives 0. The answer is plainly 0.
  3. The points share a y-coordinate, so the line is y=7y = 7.

Final answer: slope 00.

Example 3

Write the equation of the horizontal line through (2,βˆ’3)(2, -3).

  1. The height is the y-coordinate, βˆ’3-3.

Final answer: y=βˆ’3y = -3.

Example 4

Is the line through (βˆ’6,1.5)(-6, 1.5) and (8,1.5)(8, 1.5) horizontal? Write its equation.

  1. Both points have y-coordinate 1.5, so the rise is 00.
  2. Check: m=014=0m = \frac{0}{14} = 0.

Final answer: yes, y=1.5y = 1.5.

Example 5

Use the horizontal line test to decide whether f(x)=x2+1f(x) = x^2 + 1 is one-to-one.

  1. Draw y=5y = 5. It meets the graph where x2+1=5x^2 + 1 = 5, so x=βˆ’2x = -2 or x=2x = 2.
  2. One horizontal line, two meeting points: f(βˆ’2)=f(2)=5f(-2) = f(2) = 5.
  3. Cut the graph down to xβ‰₯0x \geq 0 and the restricted function is one-to-one.

Final answer: not one-to-one.

Example 6

Find the area of the rectangle enclosed by y=3y = 3, y=βˆ’1y = -1, x=βˆ’2x = -2 and x=3x = 3.

  1. Height: the gap between the horizontal lines, 3βˆ’(βˆ’1)=43 - (-1) = 4.
  2. Width: the gap between the vertical lines, 3βˆ’(βˆ’2)=53 - (-2) = 5.
  3. Area =4Γ—5=20= 4 \times 5 = 20.
two horizontal and two vertical lines enclose a rectangle
The horizontal lines y = 3 and y = βˆ’1 and the vertical lines x = βˆ’2 and x = 3 enclosing a green rectangle of height 4 and width 5, with area = 4 Γ— 5 = 20.

Final answer: 20 square units.

Where Horizontal Lines Show Up

On any graph, a horizontal stretch says one thing: the quantity on the vertical axis is not changing.

  • Heating curves. Heat ice steadily and its temperature graph goes flat at 00 Β°C while it melts and at 100100 Β°C (at sea level) while it boils. The heat changes the state, not the temperature.
  • Objects at rest. On a position–time graph, a horizontal line means the object is standing still.
  • Equilibrium. A flat stretch on a temperature–time graph marks a system neither heating nor cooling.
  • Control limits. Factory charts draw upper and lower limits as horizontal lines; a reading outside them flags a problem.
  • Building. A spirit level, a mason's string line and a surveyor's level set out the horizontal lines everything else is measured from.
the flat stretches of a heating curve are horizontal lines
A schematic heating curve of temperature against time: rising from βˆ’20 Β°C, flat at 0 Β°C while ice melts, rising, flat at 100 Β°C while water boils, then rising again.

Writing a level line as y=ky = k goes back to RenΓ© Descartes, whose 1637 work joined algebra to geometry.

Tripping Points to Avoid

Four slips catch most students on this topic.

Mistake 1: Calling a zero slope "undefined"

Where it slips in: The calculation produces 05\frac{0}{5} and the zero looks suspicious.

Don't do this: Write "undefined" whenever a 00 appears in the slope fraction.

The correct way: Look at where the zero is. Zero on top: slope 00, horizontal. Zero on the bottom: undefined, vertical. Check by multiplication, not memory.

Mistake 2: Writing x = k for a horizontal line

Where it slips in: Asked for the horizontal line at height 4.

Don't do this: Write x=4x = 4 out of habit.

The correct way: A horizontal line fixes the height, and height is yy: the equation is y=4y = 4.

Mistake 3: Mixing up the two line tests

Where it slips in: A question asks whether y=x2y = x^2 is one-to-one.

Don't do this: Run the vertical line test, see it pass, and answer "yes".

The correct way: The vertical test only shows it is a function. One-to-one needs the horizontal test, which y=x2y = x^2 fails.

Mistake 4: Saying a horizontal line has "no slope"

Where it slips in: Describing a flat line in words.

Don't do this: Say it has "no slope", which is everyday shorthand for undefined (vertical).

The correct way: A horizontal line has a slope, and it is 00. Zero is flat; undefined is upright.

Key Takeaways

  • A horizontal line keeps one fixed height, so its equation is y=ky = k, with no xx.
  • Its slope is 00: rise 0 over any run. Undefined slope belongs to vertical lines.
  • It is the graph of a constant function, f(x)=kf(x) = k.
  • It tests other functions: one horizontal line meeting a graph twice means the function is not one-to-one.

Practice These Problems to Solidify Your Understanding

Work these, then check the answers.

  1. Write the equation of the horizontal line through (6,βˆ’1)(6, -1).
  2. Is y=5y = 5 horizontal, vertical or neither, and what is its slope?
  3. Find the slope of the line through (βˆ’3,8)(-3, 8) and (5,8)(5, 8).
  4. Use the horizontal line test on y=∣x∣y = |x|.
  5. Find where y=2y = 2 meets x=βˆ’5x = -5.
  • Answer to Question 1: y=βˆ’1y = -1.
  • Answer to Question 2: horizontal, slope 0.
  • Answer to Question 3: 00. Tempted by "undefined"? Reread the zero-versus-undefined part.
  • Answer to Question 4: not one-to-one, since y=3y = 3 meets it at x=βˆ’3x = -3 and x=3x = 3.
  • Answer to Question 5: (βˆ’5,2)(-5, 2).

To practise lines and slopes with a teacher, explore Bhanzu's geometry tutor or math classes online.

Want a live Bhanzu trainer to walk your child through lines, slopes and the line tests? Book a free demo class.

Read More

Research Behind This Article

  1. OpenStax, College Algebra 2e, Section 3.7: Inverse Functions (the horizontal line test). openstax.org
  2. OpenStax, Chemistry 2e, Section 10.3: Phase Transitions (heating curves and constant temperature during melting and boiling). openstax.org
  3. MacTutor History of Mathematics, University of St Andrews, RenΓ© Descartes. mathshistory.st-andrews.ac.uk
  4. OpenStax, Elementary Algebra 2e, Section 4.4: Understand Slope of a Line (every horizontal line y=by = b has slope 0). openstax.org
  5. OpenStax, College Physics 2e, Section 2.8: Graphical Analysis of One-Dimensional Motion (the slope of a position–time graph is the velocity). openstax.org

Quick Quiz: Check Yourself

Three levels, questions with figures, instant feedback with the reason.

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

Is the x-axis a horizontal line?
Yes. It is the horizontal line y=0y = 0.
Why is the slope of a horizontal line 0 and not undefined?
Slope is rise over run. For a horizontal line the rise is 0 and the run is not, and 0 divided by a non-zero number is 0. Undefined slope happens only when the run is 0, the vertical case.
Can a horizontal line have an x-intercept?
Only the x-axis itself. Any other horizontal line, y=ky = k with k≠0k \neq 0, runs parallel to the x-axis and never meets it.
Is a horizontal line a function?
Yes, a constant function: every input gives the same output. A vertical line is the one that is not a function.
What is the difference between the horizontal line test and the vertical line test?
The vertical line test checks whether a graph is a function at all. The horizontal line test checks whether a function is one-to-one.
✍️ Written By
Prabhjot Kaur
Prabhjot Kaur
Subject Matter Expert & Curriculum Developer
Prabhjot Kaur is an education professional with 14 years of experience in teaching, curriculum development, content review and teacher training. She taught for six years in the UK and has worked as a Subject Matter Expert for competitive exams, developing and reviewing content for Numerical Ability and Logical Reasoning. She has trained teachers in effective classroom practices and designs activity-based learning experiences that make concepts easy to understand.
LinkedIn
πŸ”¬ Reviewed By
Shikha Sharma
Subject Matter Expert
Book a FREE Demo ClassBook Now β†’