You're here: Home » CSS » CSS Text Truncate with Ellipsis

CSS Text Truncate with Ellipsis

On Oct 26, 2011 under CSS

When the text exceeds the specified width it just gets cut abruptly, but instead you can end the text with ellipsis (…). To make it work you must enter a single line of text without break.

Truncate Text with Ellipsis

CSS Code

.textellipsis {
	border: 2px solid #dcdcdc;
	white-space: nowrap;
	width: 250px;
	overflow: hidden;
	text-overflow: ellipsis;
}

HTML

<p class="textellipsis">
A full line of text for testing purpose. See it in action.
</p>

Demo

A full line of text just for testing purpose. Check it up.


That’s it. Hope it works.

Comments on this entry (no comments)

Did you like this post? You can share your opinion with us! Simply click here.

Leave a Reply

CommentLuv badge