overflow:hiddenHowever, it's nice to show to users that some content is actually missing. This is typically done with an ellipsis character, that is displayed as three dots:
...Getting this working across all modern browsers has always been a pain in the neck, but there is
First, make sure you have a small
ellipsis-xbl.xmlfile on your web server that is served with the content type
text/xml, with the following contents:
<?xml version="1.0" encoding="UTF-8"?>Then mark all HTML elements you would like to show the ellipsis character on overflow with the class
<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xbl="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<xul:description crop="end" xbl:inherits="value=xbl:text"><children/></xul:description>
<div id="BreadCrumbs" class="ShyText Ellipsis">Then add the following to your CSS:
- for WebKit-based browsers (Safari, Chrome, etc.) and for Internet Explorer 7 and before;
- for Opera;
- for Internet Explorer 8;
- for Gecko-based browsers (Firefox, Camino, etc.)
text-overflowwill be standardized as of the CSS 3 standard, which is currently still in draft.
Credit for the Gecko solution go to Rikkert Koppes and William Khoe, see the article text-overflow: ellipsis for firefox.
Update (Oct. 22, 2008): The solution for Gecko-based browsers (Firefox, etc.) is far from perfect. The solution has at least the following issues:
- applying the
.Ellipsisclass to an inline element causes the element to disappear;
- in Firefox 3.0 (not in Firefox 2.0), soft hyphens inside
.Ellipsiselements always show as dashes;
- text inside a
.Ellipsiselement can no longer be selected.
Update (August 13, 2009): Don't expect the solution to go into Firefox 3.6/Gecko 1.9.2 (scheduled for release fall 2009), the bug has been tagged as "-wanted1.9.2" (starting with a minus-sign) meaning it's not planned for the upcoming release. It may still go into Firefox 3.7, which is tentatively scheduled for release in 2010, see the Mozilla Project Meeting Minutes of July 20, 2009.