Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make cross browser css ellipsis?

Tags:

html

css

firefox

I used this

p.test {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;}

but it's not working on Firefox. And I didn't check on other browsers.

But I need cross browser compatibleway

like image 502
Jitendra Vyas Avatar asked May 13 '11 10:05

Jitendra Vyas


People also ask

How do you make an ellipsis in CSS?

To clip at the transition between characters you can specify text-overflow as an empty string, if that is supported in your target browsers: text-overflow: ''; . This keyword value will display an ellipsis ( '…' , U+2026 HORIZONTAL ELLIPSIS ) to represent clipped text.

How do you overflow text in CSS?

A text-overflow property in CSS is used to specify that some text has overflown and hidden from view. The white-space property must be set to nowrap and the overflow property must be set to hidden. The overflowing content can be clipped, display an ellipsis ('…'), or display a custom string.

How do you add ellipses in HTML?

To add an ellipsis in the HTML <span> element having the CSS overflow property set to “hidden”, you need to add the text-overflow property. Use its “ellipsis” value, which will add dots at the end of the content within the <span>.


1 Answers

Firefox doesn't support it.

There's a work-around for Firefox 3.x, but that also doesn't work in FF4.

I'm told that they plan to add support in FF6.

As of this moment, there is no CSS solution that works correctly for Firefox. There are some attempts that have managed to get something close, but nothing that's actually right.

For more, see also this question: text-overflow:ellipsis in Firefox 4? (and FF5)

My current solution is to give up on having an ellipsis, and do something else instead. I'm using a fade-out effect on the right-hand side of the text element to give a similar visual cue to the user as an ellipsis, and it can even be combined with an ellipsis so we can support all browsers to show some kind of effect to show a text run-on without having to resort to any browser hacks.

UPDATE as per Ilee's answer:

Since Firefox version 7 text-overflow: ellipsis is supported. Thus, it is cross browsers for major browsers like start from FF7, IE7 and Chrome.

like image 180
Spudley Avatar answered Nov 15 '22 07:11

Spudley