Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

text-overflow:ellipsis on a link

Tags:

css

I want to use text-overflow property on a link. I work for a paragraph but not for a link.

Here is the HTML code

<div>   <ul>     <li>         <p>the text is too long</p>     </li>        <li>          <a href="javascript:alert('test')">the link is too long</a>     </li>   </ul> </div> 

Here is the css code :

a {   white-space: nowrap;   width:50px;    overflow: hidden;   text-overflow: ellipsis;  } p {   white-space: nowrap;   width:50px;    overflow: hidden;   text-overflow: ellipsis; } 

See example on http://jsfiddle.net/corinnekm/LLVDB/

Thanks a lot for your help.

like image 263
Corinne Kubler Avatar asked Oct 10 '12 13:10

Corinne Kubler


People also ask

How do I add an ellipsis to a text-overflow?

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.

What does text-overflow ellipsis mean?

Definition and Usage The text-overflow property specifies how overflowed content that is not displayed should be signaled to the user. It can be clipped, display an ellipsis (...), or display a custom string.


1 Answers

an <a> tag is an inline element, you can only apply ellipsis to a block element, try a { display: block; } and it works

like image 88
Andy Avatar answered Sep 20 '22 18:09

Andy