Skip to content

Design4 min read

How to Truncate Text in Webflow Easily

Introduction

ApproachMethodBenefit
JavaScript (this tutorial)CSS class scriptPrecise control by character count
Native Webflow CSStext-overflow: ellipsisSimple, no code, truncates by line
CSS -webkit-line-clampVia CSS embedLimits to N lines without JS

In this tutorial, Sandro, cofounder of the Gemeos Webflow agency, shows you how to easily truncate text in Webflow.

Truncating text can be super useful for a few reasons, especially when you want to keep your Hub pages consistent, like blog pages, guides, articles, and more. It helps keep the layout consistent no matter how long your text is (see image below).

Example of truncated text in Webflow

Here’s how you can do the same in under 5 minutes

1. Add a class to the text you want to truncate

In my example, I use the class "slice"

Webflow CSS class example

2. Add this code to your project

You can add this code in an embed or directly in the body of your page

<script>
  document.addEventListener('DOMContentLoaded', function () {
    var elements = document.getElementsByClassName('slice');
    var characterLimit = 64;

    for (var i = 0; i < elements.length; i++) {
      var currentElement = elements[i];

      if (currentElement.textContent.length > characterLimit) {
        currentElement.textContent = currentElement.textContent.slice(0, characterLimit) + '...';
      }
    }
  });
</script>

Make sure you replace "slice" with your CSS class

3. Adjust the character length to the value you want

All you need to do is replace the 64 in the code above with your own value. It’s that simple!

4. Publish and you’re done!

That’s all there is to it 😎

Published on Apr 10, 2025

Sandro DA SILVA

Growth Marketer, Webflow expert, and jack-of-all-trades. Sandro handles commercial operations, ensures projects run smoothly, and addresses marketing-related issues (SEO, Tracking, Copywriting, etc).

You're going to working with us, guaranteed

Ready to launch your business?

get a quote

Let’s f*****G GO !!