Dev Helpers
← Back

Truncate a single line with an ellipsis

Truncate a single line with an ellipsis with native CSS. The preview includes a small shared demo stylesheet.

Open this example in the interactive library

Source code

<style>
  .demo {
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
</style>
<div class="demo">
  A long filename that will not fit in the available space.pdf
</div>