Is there any way to strictly enforce the line height of the whole paragraph or div?
I am using HTML+CSS for typography-precise printing of books, and I want each line to really have the same height, no matter what will be inside the line.
The common problems are with superscripts or enlarged portions of text, which are (more or less successfully) dealt with in several other questions here, on SO:
- HTML
<sup />
tag affecting line height, how to make it consistent? - How to strongly force line-height in css, with no stretches?
However, the problem with these solutions is that they are partial and fix only specific cases. I don't want to fix the particular problems, I want to make sure that these problems wouldn't have a chance to appear at all. I cannot be sure in advance what different kinds of elements may appear in the whole text, so I want to make sure that the lines stay the same and instead, in case of problems, fix particular cases where I need the line to grow because of some elements.
So the problems in previous "solutions", particularly:
<sup>
tag solution requires manual playing with several sizes until it gets correct.- Second thread does not really solve the problem. When portion of text gets sufficiently big, no combination of
display:inline-block;
,overflow:hidden;
andvertical-align:top;
will do—the line will eventually grow.
What I have tried:
In short, see this JSFiddle.
I have tried applying all the combinations of these CSS rules:
display: inline-block;
(or justinline
)overflow: hidden;
vertical-align: top;
line-height: 1px;
However, changing text size to big enough still causes the lines to get bigger. And adding images (e.g. graphical smilies, which could be just 1 pixel higher than normal line height), will cause the lines to get bigger, again.
What I want:
- Ideally, I want a solution that will make sure these problems wouldn't appear at all. I don't mind trimming the large elements on top/bottom or both sides;
- If (1) is not possible, then I need at least a way to highlight and clearly see each line where this happens. In other words, if any line gets just 1px higher, I need it to draw my attention even when just skimming the text.