The slope of a vertical line is its “rise over run.” Given any “slanting” line, we can take any two points and form an right triangle. The rise of the line is the length of the vertical side of the right triangle and its run is the length the horizontal side. Of course, we have learned that the slope of a line slanting on the left hand side is negative, and the slope of a line slanting to the right hand side is positive.
For a horizontal line, we only have the run and we have 0 rise. So, we divide 0 by the run which equals 0.
That is the reason why the slope of a horizontal line is 0.
For a vertical line, we only have the rise and we have 0 run. So, we divide rise by 0. We have learned that any number divided by 0 is undefined.