In aviation terms, ‘height’ means the vertical distance of the drone from a specified point of datum (in this case above the surface of the earth).
To cater for the few occasions where a drone is being flown over hilly/undulating terrain or close to a cliff edge, the 400 ft height above the surface requirement may be interpreted as being a requirement to remain within a 400 ft distance from the surface, as shown in the diagram below.
Remember that the limitation applies to heights above/distances from the surface of the earth. It does not automatically apply to heights/distances from tall buildings or other structures.
For more information head to Civil Aviation Authority website here