Vertical Line — Equation, Slope, and Examples

#Geometry
TL;DR
A vertical line is a straight line where every point shares the same x-coordinate, so its equation is x = a and its slope is undefined (the run is zero, and you cannot divide by zero). This article covers the definition, the equation, why the slope is undefined, the vertical line test, six worked examples, and the errors students make most.
BT
Bhanzu TeamLast updated on June 25, 20269 min read

What Is A Vertical Line?

A vertical line is a line on the coordinate plane that runs straight up and down, parallel to the y-axis, in which every point has the same x-coordinate regardless of its y-coordinate. Because it never leans left or right, it crosses the x-axis at exactly one place and never crosses the y-axis at all (unless it is the y-axis).

That single shared x-coordinate is the whole identity of the line. If you know that a line passes through $(3, -2)$ and is vertical, you already know it passes through $(3, 0)$, $(3, 100)$, and $(3, -47)$. The x-value is fixed; the y-value roams free. Compare that with a horizontal line, where the roles swap — the y-coordinate is fixed and the x-coordinate is free.

What Is The Equation Of A Vertical Line?

The equation of a vertical line is x = a, where $a$ is the constant x-coordinate shared by every point on the line. Here $a$ is a fixed real number — the x-intercept — and $y$ does not appear in the equation at all, because $y$ can be anything.

The variable glossary is short:

  • $x$ — the coordinate that stays locked to one value.

  • $a$ — that locked value, the x-intercept where the line crosses the x-axis.

  • $y$ — absent from the equation on purpose, because it takes every value.

So the line one unit right of the y-axis is $x = 1$. The y-axis itself is $x = 0$. A line three units left is $x = -3$. There is no $m$ and no $b$ here, which is the first sign that this line does not behave like the lines in the slope-intercept form $y = mx + b$.

Why Is The Slope of A Vertical Line Undefined?

The slope of a vertical line is undefined, and that word is precise — it does not mean "zero" and it does not mean "infinity." It means the slope formula returns an expression with no numerical value. Here is the derivation, one step at a time.

Slope measures rise over run between two points $(x_1, y_1)$ and $(x_2, y_2)$:

$$m = \frac{y_2 - y_1}{x_2 - x_1}$$

Take any two points on the vertical line $x = 3$, say $(3, 1)$ and $(3, 4)$.

Substitute the coordinates:

$$m = \frac{4 - 1}{3 - 3}$$

Simplify the numerator and the denominator:

$$m = \frac{3}{0}$$

Division by zero is undefined.

So $m = \dfrac{3}{0}$ has no value. The numerator (the rise) is a real change in $y$, but the denominator (the run) is $0$ because both x-coordinates are the same. A fraction with $0$ on the bottom is not a number, so we say the slope is undefined. This is the single most important fact about vertical lines, and it follows directly from the definition — same x-coordinate everywhere means zero run, always.

Is the slope of a vertical line zero or undefined?

It is undefined. A slope of zero belongs to a horizontal line, where the rise is $0$ and the run is non-zero, giving $m = 0$. The two cases are mirror images, and mixing them up is the most common error here. A flat line has zero slope; an upright line has undefined slope.

What Is The Vertical Line Test?

The vertical line test is a quick visual check for whether a graph represents a function: if any vertical line drawn across the graph touches the curve at more than one point, the graph is not a function. The logic ties straight back to the definition — a vertical line holds $x$ fixed, so two intersection points would mean one $x$-value mapping to two $y$-values, which a function is not allowed to do.

This is a small but useful payoff of understanding vertical lines deeply: the same property that makes their slope undefined is the property that makes them the perfect tool for testing functions.

Examples of Vertical Line

Example 1

Write the equation of the vertical line passing through the point $(5, 9)$.

A vertical line has the form $x = a$, where $a$ is the x-coordinate.

The x-coordinate of the given point is $5$.

So the equation is $x = 5$.

The y-coordinate, $9$, plays no role — any point with $x = 5$ lies on this line.

Example 2

A student is asked for the slope of the line through $(-2, 4)$ and $(-2, -3)$. They answer 0. Is that right?

Wrong path first. Seeing the two y-values $4$ and $-3$, the student reasons that the line "goes flat" and writes $m = 0$. Take a moment, though — both points have the same x-coordinate, $-2$, which means the points stack vertically, not flat.

Run the formula to check:

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

$$m = \frac{-7}{0}$$

The denominator is $0$, so the slope is undefined, not $0$. The answer of $0$ describes a horizontal line; this line is vertical. The fix is to look at the x-coordinates first: when they match, the line is vertical and the slope is undefined before you compute anything.

Example 3

Find the slope of the line $x = -8$.

The equation $x = -8$ has the form $x = a$, so it is a vertical line.

Every vertical line has the same x-coordinate at every point, giving a run of $0$.

The slope is undefined.

Example 4

The x-intercept of a vertical line is $-\dfrac{11}{3}$. Write its equation.

The x-intercept is the constant $a$ in $x = a$.

So the equation is $x = -\dfrac{11}{3}$.

Clearing the fraction gives the equivalent form $3x + 11 = 0$, which is the same line written in standard form.

Example 5

Is the line through $(7, 2)$ and $(7, 2.0001)$ vertical, and what is its slope?

Both points share the x-coordinate $7$, so the line is vertical.

The run is $7 - 7 = 0$, no matter how tiny the difference in y looks.

The slope is undefined. A near-zero rise does not rescue a zero run; the run being $0$ is what decides the case.

Example 6

A line is parallel to the y-axis and passes through $(-4, 6)$. Write its equation and state its relationship to the x-axis.

A line parallel to the y-axis is vertical, so its equation is $x = a$ with $a = -4$.

The equation is $x = -4$.

Because it runs straight up and down, it is perpendicular to the x-axis, meeting it at $(-4, 0)$ at a right angle, written $\angle$ of $90°$.

Where vertical lines actually matter

Vertical lines look like the most boring object in coordinate geometry until you notice where the "undefined" rule does real work.

  • Function testing. The vertical line test decides whether a relationship is a function — a gatekeeper concept that runs through all of algebra and calculus.

  • Engineering and surveying. A plumb line — a weight on a string — defines true vertical for builders. A wall that drifts off vertical fails inspection, so "what counts as vertical" is a question with consequences in concrete.

  • The limits of a model. When a quantity changes with no corresponding change in its input, graphs show a vertical jump. Recognising that an undefined slope marks a place where a normal rate-of-change description breaks down is the seed of ideas you will meet later in calculus, where vertical tangents and asymptotes carry the same warning.

The deeper point: "undefined" is not a failure of the math. It is the math telling you, precisely, that this particular line cannot be measured by steepness — and that information is useful.

Where students trip up on vertical lines

Mistake 1: Calling the slope "zero" instead of "undefined"

Where it slips in: The moment two points share an x-coordinate and the student rushes to a number.

Don't do this: Writing $m = 0$ for a line like $x = 4$ because it "doesn't go anywhere."

The correct way: Check the run first. If $x_2 - x_1 = 0$, the slope is undefined; a horizontal line (same y-coordinates) is the one with slope $0$.

The first instinct on a vertical line is to treat "no movement" as "flat," and that swap between zero and undefined is the single error that shows up most often. Naming which coordinate is shared — x or y — settles it every time, and it is worth slowing down for that one check.

Mistake 2: Writing the equation as y = a

Where it slips in: When students pattern-match to $y = mx + b$ and reach for $y$ out of habit.

Don't do this: Writing $y = 3$ for a line through $(3, 5)$ that is meant to be vertical.

The correct way: A vertical line fixes $x$, so its equation is $x = a$. The equation $y = a$ describes a horizontal line. The memorizer who learned "lines look like $y = \ldots$" gets caught here; the cure is to remember that the fixed coordinate names the equation.

Mistake 3: Trying to find a y-intercept

Where it slips in: On a worksheet that asks for the y-intercept of every line in a list.

Don't do this: Forcing a y-intercept for $x = 2$.

The correct way: A vertical line $x = a$ (with $a \neq 0$) never crosses the y-axis, so it has no y-intercept. Only the y-axis itself, $x = 0$, touches the y-axis — along its whole length.

Key Takeaways

  • A vertical line has the equation $x = a$, where $a$ is the shared x-coordinate of every point on the line.

  • The slope of a vertical line is undefined because the run is $0$ and division by zero has no value — it is never zero.

  • A horizontal line is the mirror case: slope $0$, equation $y = b$.

  • Vertical lines have an x-intercept but no y-intercept (unless the line is the y-axis itself).

  • The vertical line test uses this property to decide whether a graph is a function.

A Practical Next Step

Practice these problems to solidify your understanding. Sketch each line on a grid first, then write its equation and state its slope:

  1. The vertical line through $(6, -1)$.

  2. The slope of the line through $(0, 4)$ and $(0, -9)$.

  3. The equation of the line parallel to the y-axis with x-intercept $-\dfrac{5}{2}$.

If the zero-versus-undefined distinction still feels slippery, reread the slope derivation above and compare it side by side with a horizontal line. To see how a vertical line sits among intersecting lines and the x and y axes, follow those threads next. Want a live Bhanzu trainer to walk through more vertical-line problems? Book a free demo class.

Answer to Question 1: $x = 6$.

Answer to Question 2: undefined (run $= 0$).

Answer to Question 3: $x = -\dfrac{5}{2}$.

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

What is the equation of a vertical line?
It is $x = a$, where $a$ is the constant x-coordinate every point on the line shares. The line $x = 5$ passes through every point whose x-value is $5$.
What is the slope of a vertical line?
Undefined. The run between any two points is $0$, and dividing the rise by $0$ has no value.
Are vertical lines functions?
No. A vertical line maps one x-value to infinitely many y-values, and a function allows only one output per input — which is exactly what the vertical line test detects.
Is a vertical line parallel or perpendicular to the y-axis?
Parallel to the y-axis and perpendicular to the x-axis. The y-axis is itself the vertical line $x = 0$.
How is a vertical line different from a horizontal line?
A vertical line is $x = a$ with undefined slope; a horizontal line is $y = b$ with slope $0$. They are perpendicular to each other.
Can a vertical line have a negative equation?
Yes. $x = -3$ is a vertical line three units to the left of the y-axis. The sign just places it left or right.
✍️ Written By
BT
Bhanzu Team
Content Creator and Editor
Bhanzu’s editorial team, known as Team Bhanzu, is made up of experienced educators, curriculum experts, content strategists, and fact-checkers dedicated to making math simple and engaging for learners worldwide. Every article and resource is carefully researched, thoughtfully structured, and rigorously reviewed to ensure accuracy, clarity, and real-world relevance. We understand that building strong math foundations can raise questions for students and parents alike. That’s why Team Bhanzu focuses on delivering practical insights, concept-driven explanations, and trustworthy guidance-empowering learners to develop confidence, speed, and a lifelong love for mathematics.
Related Articles
Book a FREE Demo ClassBook Now →