Take the 2-minute tour ×

the following fiddle demonstrates the problem:


this is using jquery.dotdotdot plugin for truncating text with an ellipsis.

when there's a single word like a_really_long_filename_with_no_spaces_at_all.txt that overflows a div, this plugin does not truncate it. is there any way to make this happen?

the html:

  <div id="wrapper">this_does_not_truncate_because_there_are_no_spaces</div>
  <div id="wrapper2">this one has spaces and is truncated properly</div>

​ the javascript:

 $("#wrapper").dotdotdot({wrap: 'letter'});
 $("#wrapper2").dotdotdot({wrap: 'letter'});

the css:

#wrapper {
    width: 100px;
    height: 20px;
    border: 1px solid red;
#wrapper2 {
    width: 100px;
    height: 20px;
    border: 1px solid red;
share|improve this question
CSS3 has a function but since you using jQuery i think that is not good. Looks like you can report a bug. Just a simple thing in the code. –  ppumkin Nov 10 '12 at 0:42

1 Answer 1

up vote 2 down vote accepted

Do you really need a plugin to do this? Have you tried using the CSS text-overflow:ellipsis? It's supported by every single browsers except really old ones like IE 5.5 or below or FF 6 or below.

More information on text-overflow: https://developer.mozilla.org/en-US/docs/CSS/text-overflow

A demo page: http://davidwalsh.name/demo/css-ellipsis.php

share|improve this answer
show me in the fiddle how you'd get that to work? i can't get css text-overflow truncation to happen in chrome on osx. –  inconduit Nov 10 '12 at 1:27
@inconduit I have edited my answer with a demo page. Works on Chrome OSX. Not a fiddle, but you should be able to inspect it to see how it works. –  pixelfreak Nov 10 '12 at 7:26
@pixelfreak it might be also worth noting that as far as I can tell text-overflow truncation only seems to work on a single line of text not multiple lines? –  ak85 Nov 10 '12 at 7:42
@ak85 Yes, that is correct. inconduit, if you are looking for a multi-line ellipsis, then you'll have to resort to JS. –  pixelfreak Nov 10 '12 at 8:03

Your Answer


