# Limit Post Titles and Excerpts to a Few Lines in Grids

> Cuts long post titles to two lines and excerpts to three lines in blog grids and Query Loop blocks, so cards line up neatly whatever the text length.

- Type: CSS
- Runs: Site-wide header
- Category: [Frontend & Design](https://wpide.com/library/category/frontend/)
- Tags: archives, query-loop, typography, layout
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/frontend-clamp-archive-titles/

## Code

```css
.wp-block-post-template .wp-block-post-title,
.blog .entry-title,
.archive .entry-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
}

.wp-block-post-template .wp-block-post-excerpt__excerpt,
.blog .entry-summary p,
.archive .entry-summary p {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
}
```

## Notes

Change the line counts in -webkit-line-clamp. Full titles still show on single posts.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Limit Post Titles and Excerpts to a Few Lines in Grids" in its snippet library and add it in one click; or create a new CSS snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
