The CSS specification dictates that line-height should be implemented by dividing the specified value by two and applying the result both above and below a line of text.
This significantly differs from the traditional concept of leading, where spacing is typically only added above a line of text. (I understand this oversimplifies the role of line-height, but it helps explain the issue more clearly).
Take a look at this example markup:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
p
{
margin:0;
font-size: 13pt;
line-height: 15pt;
}
h1
{
margin:0;
font-size: 21pt;
line-height: 30pt;
}
</style>
</head>
<body>
<h1>Title</h1>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</p>
<p>Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
<p>It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.</p>
</body>
</html>
If line-height functioned like traditional leading, then the distance between <h1>
and the first <p>
would match the distance between subsequent <p>
s due to the consistent leading. However, this is not the case.
While the distance between <p>
s remains constant (
p's line-height - p's font-size = 15 - 13 = 2pt
), the gap between <h1>
and the initial <p>
varies: (p's line-height - p's font-size)/2 + (h1's line-height - h1's font-size)/2 = (15 - 13)/2 + (30-21)/2 = 5.5pt
.
This visual inconsistency can be easily observed when rendered in a browser.
The challenge arises from the traditional method of maintaining vertical rhythm using multiples of base leading, which CSS does not adhere to, as demonstrated above.
I have three inquiries:
- Is my interpretation of line-height, leading, and their distinctions accurate?
- Is there a way to uphold vertical rhythm in CSS (whether by emulating traditional leading or using other methods)?
- (Extra question) What was the rationale behind deviating line-height so markedly from leading?
UPDATE: Thank you for your feedback! I proposed my own solution and welcome any comments on it: