CSS text-overflow examples

Some tests with a cross-browser text-overflow solution, using the CSS attribute text-overflow for Microsoft Internet Explorer, Safari and Chrome, -o-text-overflow for Opera and -moz-binding / XBL for firefox.

A first and simple test, let the text-overflow run

But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness.

Using XBL (XML Binding Language), to implement text-overflow in Firefox, The container (dotted box) has a fixed width, the text is definitely too long for it, if it works, you should see points instead of a simple clipping in all major browsers. So let's try the same with a fluid box:

But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness.

Scale the window a bit, to see if the ellipsis is changing. Works fine? You can download this version here, but in case you don't proceed, this version has a serious bug in Firefox. If you want to use text-overflow only for text fragments without any html inside, everything is fine and you can use it, otherwise take a look on the next test, and download the improved XBL you'll find below the third example.

Get the CSS Get the smallest but improvable XBL for Firefox (You will find a better working XBL below the third example)

Second test - now trying to do the same with nested html inside the text fragment

But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness.

This time Firefox does not follow at all, in my current version (3.6.3) all nested elements disapear! Well let's try another XBL syntax.

But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness.

Not perfect, but better - I got at least the contents of the nested html elements, although it is impossible to add any styling to them. Until I find a better way, this is the best solution I can offer.

Third round - combinating text-overflow with different CSS3 attributes

But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness.

Trying to add different CSS attributes: A special font (MuseoCustom), text-shadow, different colors and a scale Transation when you click on the text. Loading of this file takes significant longer than before, but everything seems to work fine.

Get the CSS Get the improved XBL for Firefox

Last round - interacting with javascript

But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness.

Click here, to test if the text-overflow ellipsis solution still works in case you change the text dynamicly.

Found any other bugs or strange behaviour - please leave a comment in the related article.