Line height on text in HTML




What is it all about?

HTML uses single line height as default. For many texts, especially short and narrow texts this is fine, but for larger blocks of text, e.g. a short story or a novel, it can be a straining for the eyes to have such a massive block of text. Therefore it can be beneficial to adjust the line distance, to have a bit more space between the lines. You can also encounter the need for smaller line height, especially when the font size becomes smaller at line break. Here a smaller distance between lines can improve readability significantly.

Line height/distance is controlled by the variable line-height on the attribute STYLE, and can take the following values:

ValueDescription
normalNormal line helght (default).
numberA number being multiplied on the font size being used, to set the line distance (line height).
lengthA fixed line distance (line height) specified in px, pt, cm, etc.
%Line distance (line height) in percent of the font size being used.
initialSetting the value to default.
inheritInherit the value from the parent element.


Be aware that line distance in HTML is not the actual distance between the lines but the height of the lines, i.e. there is no distance between the lines to adjust.





How does it look?

This is a few lines from Kenneth Grahame's The Wind in the Willows in a DIV tag for demonstration:

The text in the original version
'Hullo, Mole!' said the Water Rat.
'Hullo, Rat!' said the Mole.
'Would you like to come over?' enquired the Rat presently.
'Oh, its all very well to TALK,' said the Mole, rather pettishly, he being new to a river and riverside life and its ways.
The Rat said nothing, but stooped and unfastened a rope and hauled on it; then lightly stepped into a little boat which the Mole had not observed. It was painted blue outside and white within, and was just the size for two animals; and the Mole's whole heart went out to it at once, even though he did not yet fully understand its uses.


Using STYLE="line-height:1.5"
'Hullo, Mole!' said the Water Rat.
'Hullo, Rat!' said the Mole.
'Would you like to come over?' enquired the Rat presently.
'Oh, its all very well to TALK,' said the Mole, rather pettishly, he being new to a river and riverside life and its ways.
The Rat said nothing, but stooped and unfastened a rope and hauled on it; then lightly stepped into a little boat which the Mole had not observed. It was painted blue outside and white within, and was just the size for two animals; and the Mole's whole heart went out to it at once, even though he did not yet fully understand its uses.


Using STYLE="line-height:50%"
'Hullo, Mole!' said the Water Rat.
'Hullo, Rat!' said the Mole.
'Would you like to come over?' enquired the Rat presently.
'Oh, its all very well to TALK,' said the Mole, rather pettishly, he being new to a river and riverside life and its ways.
The Rat said nothing, but stooped and unfastened a rope and hauled on it; then lightly stepped into a little boat which the Mole had not observed. It was painted blue outside and white within, and was just the size for two animals; and the Mole's whole heart went out to it at once, even though he did not yet fully understand its uses.


Using STYLE="line-height:30px"
'Hullo, Mole!' said the Water Rat.
'Hullo, Rat!' said the Mole.
'Would you like to come over?' enquired the Rat presently.
'Oh, its all very well to TALK,' said the Mole, rather pettishly, he being new to a river and riverside life and its ways.
The Rat said nothing, but stooped and unfastened a rope and hauled on it; then lightly stepped into a little boat which the Mole had not observed. It was painted blue outside and white within, and was just the size for two animals; and the Mole's whole heart went out to it at once, even though he did not yet fully understand its uses.