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.
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.
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.
an <a>
tag is an inline element, you can only apply ellipsis to a block element, try a { display: block; }
and it works
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With