Menu
CoddyTech

Multi-Line Previews

Part of the Responsive UI Patterns section of Coddy's Tailwind CSS journey. Lesson 33 of 55.

A card description may need a few lines rather than a single truncated label. line-clamp-2 limits a text block to two visible lines and clips the remainder while leaving the full text in the document. The example supplies a full-description link beside the preview.

<article><p class="line-clamp-2 leading-6">A longer event description appears here.</p><a href="#details">Read the full description</a></article>

Choose the line count based on the preview’s role. line-clamp-3 permits three lines; line-clamp-none removes the clamp and restores ordinary overflow. Responsive variants can remove a narrow-screen preview limit when more room is available.

Clamping is for summaries, not for hiding essential instructions or errors. Preserve access to the full content. A known line height makes the expected preview height easy to inspect without assuming a particular number of characters per line.

challenge icon

Challenge

Medium

Limit the supplied description preview to three lines of its existing 24px line height. Preserve the full text and the full-description link. The preview must clip overflow rather than expand the card.

Preserve the supplied content, semantic elements and IDs. Edit the requested utility classes. Press Run preview after edits, then Check/Run code to grade the result. Supplied JavaScript is read-only.

Keep the working full-description link and its unclamped full-text destination available.

Try it yourself

<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Interface workshop</title><link rel="stylesheet" href="./styles.css"></head><body>
<article class="w-48"><p id="summary" class="leading-6 ">A hands-on workshop explores drawing, printing, color mixing, composition and collaborative studio practice. Bring a notebook and discover several approaches with the teaching team. A hands-on workshop explores drawing, printing, color mixing, composition and collaborative studio practice. Bring a notebook and discover several approaches with the teaching team. A hands-on workshop explores drawing, printing, color mixing, composition and collaborative studio practice. Bring a notebook and discover several approaches with the teaching team. </p><a href="#full">Read full description</a></article>
<section id="full" tabindex="-1" class="mt-8"><h2>Full workshop description</h2><p id="fullText">A hands-on workshop explores drawing, printing, color mixing, composition and collaborative studio practice. Bring a notebook and discover several approaches with the teaching team. A hands-on workshop explores drawing, printing, color mixing, composition and collaborative studio practice. Bring a notebook and discover several approaches with the teaching team. A hands-on workshop explores drawing, printing, color mixing, composition and collaborative studio practice. Bring a notebook and discover several approaches with the teaching team. </p></section></body></html>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Responsive UI Patterns