Consider the given diagram.
To construct a perpendicular line to AB at point P, we open the compass to a size greater than the distance between P and the line. Then, we place the sharp end of the compass at P and draw an arc that intersects the line twice.
Next, we place the compass at one of the intersections and make an arc below the line.
Using the same compass settings, we draw a second arc below the line, placing the compass at the other intersection.
Finally, we draw a line from P to the intersection of the arcs using a straightedge.
This line is perpendicular to AB and goes through P.