Q:

How do you control line spacing in HTML?

A:

Quick Answer

According to W3Schools.com, a user can set the line height in HTML in percent of the text font size. For example: p.small {line-height: 90%;} or p.big {line-height: 200%;}. Another option is entering a number that sets the height by being multiplied with the font size. For example: p.small {line-height: 0.5;} or p.big {line-height: 2;}.

Continue Reading

Full Answer

CSS-Tricks.com recommends using the number option, which is referred to as "unitless" line height. The "unitless" method is preferred due to the ability for the child element to be based on the computed font size, rather than inheriting the raw number value from the parent element. This cuts down the need for overriding, because the child number value is not based on the arbitrary parent value.

W3Schools.com states that line height also can be set using a fixed height in pixels, point, centimeters and so on. An example in pixels is: p.small {line-height: 10px;} or p.big {line-height: 30px;}.

It also is possible to set the line height using the inherit keyword, which allows a property, such as line height, to inherit the value of the parent element. Another keyword to use for line height is the initial keyword, which is used to set line height back to the default value.

Learn more about Computer Programming

Related Questions

Explore