To achieve the desired effect, ensure that your CSS includes properties such as overflow
, width
(or max-width
), display
, and white-space
.
http://jsfiddle.net/HerrSerker/kaJ3L/1/
span {
border: solid 2px blue;
white-space: nowrap;
text-overflow: ellipsis;
width: 100px;
display: block;
overflow: hidden
}
body {
overflow: hidden;
}
span {
border: solid 2px blue;
white-space: nowrap;
text-overflow: ellipsis;
width: 100px;
display: block;
overflow: hidden
}
<span>Test test test test test test</span>
Addendum
If you are interested in various techniques for line clamping (Multiline Overflow Ellipses), check out this resource from CSS-Tricks: https://css-tricks.com/line-clampin/
Addendum2 (May 2019)
According to this source, Firefox 68 will soon support -webkit-line-clamp
!