Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A jQuery/YUI3 plugin to truncate strings that are too l ...
JavaScript Shell CSS
branch: master


Ellipsis is a set of JavaScript plugins I created to emulate text-overflow: ellipsis; before it was implemented in modern browsers.

Why would I use this now?

The benefits that this library still offers over simply using CSS (as of 4/4/2014) are:

  • uses native (text-overflow: ellipsis;) support when possible
  • offers a fallback if native support isn't available
  • supports multi-line overflow handling (e.g. 3 lines then …)

Demos (jQuery) (YUI)


You can pass a few things to the plugin to change how it behaves. Here are the parameters and their defaults:

  'lines'    : 1,         // the number of lines before truncating
  'ellipsis' : '\u2026',  // the truncation character to use
  'fudge'    : 0,         // the number of extra characters to remove
  'remember' : true,      // whether or not to save the text before truncating (useful when resizing)
  'native'   : true       // whether to use native browser support when it exists



<span class=ellipsis>Lots and lots of text!</span>
<script src=jquery.js></script>
<script src=jquery.ellipsis.js>
  function ellipsize() { $('.ellipsis').ellipsis(); }
  $(ellipsize);  // when document is ready
  $(window).on('resize', ellipsize);  // on resize


<span class=ellipsis>Lots and lots of text!</span>
<script src=yui-loader.js></script>
  // there's already a gallery module, so you can juse use 'gallery-ellipsis'.
  YUI().use('gallery-ellipsis', function(Y) {
    function ellipsize() { Y.all('.ellipsis').ellipsis(); }
    Y.on(['domready', 'windowresize'], ellipsize);

There's a few more examples on the YUI gallery page as well.

Something went wrong with that request. Please try again.