jQuery Plugin To Split Text By Lines - SplitLines

File Size: 6.25 KB
Views Total: 5116
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
jQuery Plugin To Split Text By Lines - SplitLines

SplitLines is a lightweight jQuery plugin that allows you to split a block of text into separate lines using specific html tag(s) based on the width of the box or a width passed to the function. Then you can style and animate each line individually.

How it works:

  1. Splits contents into words, keeping their original Html tag. Note that this tags *each* word with the tag it was found in, so when the wrapping begins the tags stay intact. This may have an effect on your styles (say, if you have margin, each word will inherit those styles).
  2. Splits words by spaces.
  3. Formats html with tags and wrappers.

See Also:

How to use it:

1. Load the main JavaScript file after jQuery library and we're ready to go.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="jquery.splitlines.js"></script>

2. Call the plugin with default options on the text wrapping element and done. By default, the plugin tries to use the element's width. If you don't define a width, there's no way to split it by lines.


3. Set the HTML tag to wrap the lines in:

  tag: '<div>'

4. Determine Whether or not to try and preserve the html within the element.

  keepHtml: true

5. Set a given width to the text lines.

  width: 200



  • Added support for --line-index with older versions of jQuery


  • Fixed auto-width not sizing elements properly


  • Preserving html line breaks.

This awesome jQuery plugin is developed by jeremyharris. For more Advanced Usages, please check the demo page or visit the official website.