The default font is depends on browser, so in Windows/Chrome environment I noticed that it to truncate text by overflow
, white-space
, text-overflow
, the part of text below underline becomes invisible.
For font-size: 14px
and line-height: 14px
all letters are almost visible, just a part of g
letter has been cropped. For font-size: 12px
and line-height: 12px
, the visibility is worse: the lower part of j
and g
has been cropped:
.test1{
width: 200px;
font-size: 14px;
line-height: 14px;
background: lightsalmon;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.spacer{
height: 30px;
}
.test2{
width: 200px;
font-size: 12px;
line-height: 12px;
background: lightsalmon;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
<div class="test1">jane glad TestThatVerHardToBreakAlasdfjsdfjkjsdfjkosdfjoisdfjiosdfijdsfijowioqjrfiwqjfiw</div>
<div class="spacer"></div>
<div class="test2">jane glad TestThatVerHardToBreakAlasdfjsdfjkjsdfjkosdfjoisdfjiosdfijdsfijowioqjrfiwqjfiw</div>
Of course if we change the line height, text becomes fully visible. But:
- I don't want to change the
line-height: 1;
for single-line elements. - Even I need change line-height, I need to do some experiments to select the line-height value such as text will be fully visible. So, the line-height value will be hard-coded.
Is here some solution which does not depend on font size and line height?