…
).overflow: hidden
to prevent the text from overflowing its dimensions.white-space: nowrap
to prevent the text from exceeding one line in height.text-overflow: ellipsis
to make it so that if the text exceeds its dimensions, it will end with an ellipsis.width
for the element to know when to display an ellipsis.<p class="truncate-text">If I exceed one line's width, I will be truncated.</p>
.truncate-text { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; width: 200px; }
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️