truncate.js: Versatile Plugin For Truncating Text Examples

Download This Plugin Back To jQueryScript

A lightweight and flexible JavaScript/jQuery plugin that allows you to truncate text content on a webpage based on the number of lines you specify.

Position

End (default)

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

Middle

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

Start

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

Line height

With line-height specified

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

line-height auto detect (no css line height specified)

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

line-height auto detect (css line height specified)

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

Box

No spill

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

No margin and padding

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

With padding. No margin.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

With padding. With margin.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

With padding. With thick borders.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

No margin and padding (border box)

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

With padding. No margin. (border box)

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

With padding. With margin. (border box)

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

With padding. With thick borders. (border box)

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

With nested elements

Ignore comment nodes

Lorem Ipsum is simply dummy texts of the printing and typesetting industry.
Lorem Ipsum is simply dummy texts of the printing and typesetting industry.
Lorem Ipsum is simply dummy texts of the printing and typesetting industry.

single block wrap

Members, friends, adversaries, competitors, and colleagues
Members, friends, adversaries, competitors, and colleagues
Members, friends, adversaries, competitors, and colleagues

double block wrap

Members, friends, adversaries, competitors, and colleagues
Members, friends, adversaries, competitors, and colleagues
Members, friends, adversaries, competitors, and colleagues

double inline wrap

Members, friends, adversaries, competitors, and colleagues
Members, friends, adversaries, competitors, and colleagues
Members, friends, adversaries, competitors, and colleagues

single wrap with margin

Members, friends, adversaries, competitors, and colleagues

Members, friends, adversaries, competitors, and colleagues

Members, friends, adversaries, competitors, and colleagues

single break tag

Members, friends, adversarie
s, competitors, and colleagues
Members, friends, adversarie
s, competitors, and colleagues
Members, friends, adversarie
s, competitors, and colleagues

double break tags

Members, friends, adversarie

s, competitors, and colleagues
Members, friends, adversarie

s, competitors, and colleagues
Members, friends, adversarie

s, competitors, and colleagues

lists

  • Members
  • Friends
  • Adversaries
  • Members
  • Friends
  • Adversaries
  • Members
  • Friends
  • Adversaries

nested lists

  1. Members
  2. Friends
    • Noobs
    • Educators
    • Adversaries
  1. Members
  2. Friends
    • Noobs
    • Educators
    • Adversaries
  1. Members
  2. Friends
    • Noobs
    • Educators
    • Adversaries

floated elements

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

single wrap with padding

Members, friends, adversaries, competitors, and colleagues