The slope of any horizontal line is always zero. The word "slope" is defined as the incline or the steepness of a straight line. If a line is horizontal, there is no incline.
The formula for slope is (y2 - y1) / (x2 - x1). Since slope is expressed as a ratio of the rise of the line divided by the run, and there is no change in altitude from one point on the line to another, the slope of a horizontal line is zero. The slope of a vertical line is considered undefined, as x1 would always equal x2, so the difference between them is zero; when any number is divided by zero, the result is undefined.