Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                meta(name="viewport" content="width=device-width, initial-scale=1")
  h1 Truncated Text Demo
  p A demo on how to truncate text within a given text space, e.g. list item.
  p Move the slider right or left to show or hide characters...
    input(type="range" id="range-limit" value="100" min="1" max="200")
    output#current-limit 100
    li#text-1 Lorem Ipsum is simply dummy text of the printing and typesetting industry.
    li#text-2 Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took

  p Notice that the maximum number of characters displayed is #[strong never beyond the set value]
  p ... And there is #[strong: s no broken words].


                html, body {
  height: 100%;

body {
background-image: linear-gradient(30deg, #445 12%, transparent 12.5%, transparent 87%, #445 87.5%, #445),
linear-gradient(150deg, #445 12%, transparent 12.5%, transparent 87%, #445 87.5%, #445),
linear-gradient(30deg, #445 12%, transparent 12.5%, transparent 87%, #445 87.5%, #445),
linear-gradient(150deg, #445 12%, transparent 12.5%, transparent 87%, #445 87.5%, #445),
linear-gradient(60deg, #99a 25%, transparent 25.5%, transparent 75%, #99a 75%, #99a), 
linear-gradient(60deg, #99a 25%, transparent 25.5%, transparent 75%, #99a 75%, #99a);
background-size:80px 140px;
background-position: 0 0, 0 0, 40px 70px, 40px 70px, 0 0, 40px 70px;

main {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 300px;
  width: 100%;
  margin: auto;
  padding: 25px;
  box-shadow: inset 0 4px 5px #100;
  background: hsla(0, 100%, 100%, 0.9);

h1, p, div, input, output {
  box-sizing: border-box;
  display: block;
  margin: 0 auto;
  width: 100%;
  margin-top: 20px;
  text-align: center;

div {
  padding: 20px;
  box-shadow: 0 0 5px #333;
  font-size: 1.1rem;
  font-weight: bolder;
  background: white;
  transition: background 300ms ease, box-shadow 300ms ease;
  &:hover {
    background: hsl(110, 80%, 90%);
    box-shadow: 0 0 2px hsl(70, 20%, 50%);
  input {
    cursor: pointer;
  output:after {
    content: " chars max";

li {
  font-family: monospace;
  font-size: 1.1rem;
  transition: color 300ms ease-in;
  &.is-changed {
    color: red;


                function truncate(string, limit) {
	if (!string) return;
  if (string.length < limit) return string;
  var substring = string.substring(0, limit);
  var spacePosition = substring.lastIndexOf(' ');
  if (spacePosition === substring.length) return substring;
  else return substring.substring(0, spacePosition) + '...';

var domLimit = document.querySelector('#range-limit');
var domText1 = document.querySelector('#text-1');
var domText2 = document.querySelector('#text-2');
var domOutput = document.querySelector('#current-limit');

domText1.dataset['original'] = domText1.innerText || domText1.textContent;
domText2.dataset['original'] = domText2.innerText || domText1.textContent;

domLimit.onchange = function () {
	var limit = domLimit.value;
  domOutput.innerText = limit;
	domText1.innerText = domText1.textContent = truncate(domText1.dataset['original'], limit);    

  domText2.innerText = domText2.textContent = truncate(domText2.dataset['original'], limit);
  setTimeout(function () {
  }, 400);