Dev Helpers
← Back

Clamp a paragraph to two lines

Clamp a paragraph to two lines with native CSS. The preview includes a small shared demo stylesheet.

Open this example in the interactive library

Source code

<style>
  .demo {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    max-width: 24ch;
  }
</style>
<p class="demo">
  A long paragraph is still present in the markup. Only the first two lines fit
  in this compact card.
</p>