5

I'm attempting to get ellipsis working on my site. This is the following HTML / CSS code and it doesn't appear to be working.

CSS:

.oneline { text-overflow:ellipsis; white-space: nowrap; width: 50px; overflow: hidden; } 

HTML:

<div class="oneline">Testing 123 Testing 456 Testing 789</div> 
6
  • 1
    Are you sure you're using a CSS3 compliant browser? Commented May 25, 2012 at 23:35
  • Check out this answer if you're on FF: stackoverflow.com/questions/4927257/… Commented May 25, 2012 at 23:37
  • Looks fine to me jsfiddle.net/ZBQnL Commented May 25, 2012 at 23:38
  • Working fine in latest versions of Chrome, FF, and IE9 Commented May 25, 2012 at 23:39
  • This shouldn't even need a CSS3 compatible browser - even IE6 renders white-space:nowrap and text-overflow:ellipsis correctly. Commented May 25, 2012 at 23:47

2 Answers 2

11

Based on the initial post, we're all assuming the obvious, but just in case ... ;)

<style type="text/css"> .oneline { text-overflow : ellipsis; white-space : nowrap; width : 50px; overflow : hidden; } </style> <div class="oneline">Testing 123 Testing 456 Testing 789</div> 

http://jsfiddle.net/NawcT/

EDIT: Solution was to style the paragraph vs the div.

Sign up to request clarification or add additional context in comments.

2 Comments

Seems to work fine on jsfiddle.net - I have the styling in a separate stylesheet.
Are you using multiple stylesheets? Maybe you have a resetter which is clobbering your text-overflow or overflow rules. You can try adding !important after the rule assignments to test that theory.
0

Assigning position:absolute to the element to be truncated will probably have less undesired side-effects that float:left.

This worked for me:

div { position: absolute; width: 70px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.