[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"verticals":3,"article-css-line-clamp-text-truncation":44,"search-suggestions":228,"path-membership-css-line-clamp-text-truncation":269,"related-css-line-clamp-text-truncation":270,"code:css:true:i6tvxq":394,"code:css:true:n5gufl":395,"code:css:true:3ijswi":396,"comments-01a21cc5-6e70-753b-8ca9-4a22a6062694":397},[4,20,32],{"id":5,"slug":6,"name":7,"tagline":8,"description":9,"accentFrom":10,"accentTo":11,"icon":12,"defaultLocale":13,"locales":14,"features":16,"position":19},"019fe637-3d33-714b-b57f-23e163ffca0c","dev","Web Development","Read it. Run it. Prove it.","A post a day on modern web development — most with an editable playground and a quiz that explains every answer. Free, no account needed.","violet-500","cyan-400","◇","en",[13,15],"fa",{"courses":17,"paths":17,"articles":17,"exams":18,"flashcards":18,"packages":17,"community":17,"certificates":17,"teams":17,"commerce":17},true,false,0,{"id":21,"slug":22,"name":23,"tagline":24,"description":25,"accentFrom":26,"accentTo":10,"icon":27,"defaultLocale":13,"locales":28,"features":30,"position":31},"019fe637-3dc2-754c-8657-0f175bfee7c6","lang","Languages","Learn a language the way you learn a codebase.","Grammar explained the way good documentation explains an API — one idea at a time, each with a quiz.","amber-400","⌘",[13,15,29],"es",{"courses":18,"paths":18,"articles":17,"exams":18,"flashcards":17,"packages":18,"community":17,"certificates":17,"teams":18,"commerce":18},2,{"id":33,"slug":34,"name":35,"tagline":36,"description":37,"accentFrom":38,"accentTo":39,"icon":40,"defaultLocale":13,"locales":41,"features":42,"position":43},"7b3c16f2-931d-410e-802e-e1fa4edab7de","soft","Soft Skills","The half of the job nobody wrote documentation for.","Weekly, on the parts of working life that decide more than your code does — first weeks, meetings, interviews, promotions, and the people around you. Written from what actually happens, and recorded as a podcast you can listen to on the walk.","emerald-400","teal-300","◉",[13],{"courses":18,"paths":18,"articles":17,"exams":18,"flashcards":18,"packages":18,"community":17,"certificates":18,"teams":18,"commerce":18},3,{"id":45,"slug":46,"title":47,"subtitle":48,"excerpt":49,"coverUrl":50,"locale":13,"readingMinutes":51,"publishedAt":52,"viewCount":53,"likeCount":19,"commentCount":19,"author":54,"vertical":59,"topic":60,"tags":63,"_count":75,"playground":77,"body":79,"bodyMd":211,"seo":212,"translationGroupId":215,"series":48,"podcastUrl":48,"verticalId":5,"thread":216,"assessments":218,"translations":224,"quiz":226},"01a21cc5-6e70-753b-8ca9-4a22a6062694","css-line-clamp-text-truncation","`line-clamp` Is Standardized Now. No Browser Ships It By Default.",null,"Every card-grid truncation trick runs through the same four lines of `-webkit-line-clamp` CSS that nobody fully understands. The standardized `line-clamp` property exists in the spec — but Safari's implementation hasn't left Safari Technology Preview, Chrome has it prototyped behind an experimental flag, and Firefox keeps it behind a flag of its own.","\u002Fmedia\u002Fcovers\u002Fcss-line-clamp-text-truncation.png",5,"2026-12-02T12:04:15.163Z",6,{"id":55,"name":56,"username":57,"avatarUrl":48,"headline":58},"019fe637-3c25-7088-9034-39c9f15dc3c8","Parsa Jiravand","parsa","Frontend engineer · building bestpractic",{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":61,"name":62},"css","CSS",[64,66,69,72],{"slug":61,"name":65,"color":48},"Css",{"slug":67,"name":68,"color":48},"webdev","Webdev",{"slug":70,"name":71,"color":48},"frontend","Frontend",{"slug":73,"name":74,"color":48},"tutorial","Tutorial",{"assessments":76},1,{"slug":46,"title":78},"line-clamp — interactive playground",{"blocks":80,"version":76},[81,85,90,93,96,99,103,106,110,113,116,119,122,125,129,132,135,138,141,144,147,150,153,156,159,162,165,168,171,174,177,180,183,186,193,196,199,202,205],{"id":82,"html":83,"type":84},"b1","\u003Cp>Open any card grid — a blog&#39;s post list, a product catalog, a comment thread — and find the one where the description is cut off after three lines with a neat little \u003Ccode>…\u003C\u002Fcode>. Then view source on the CSS. It&#39;s always the same four lines, and I&#39;d bet money whoever wrote them couldn&#39;t tell you why all four are required.\u003C\u002Fp>","paragraph",{"id":86,"code":87,"type":88,"language":61,"highlight":89},"b2",".card-desc {\n  display: -webkit-box;\n  -webkit-box-orient: vertical;\n  -webkit-line-clamp: 3;\n  overflow: hidden;\n}","code",[],{"id":91,"html":92,"type":84},"b3","\u003Cp>\u003Ccode>-webkit-line-clamp\u003C\u002Fcode> is a non-standard, vendor-prefixed property that&#39;s been in Blink and WebKit since around 2010. It&#39;s not part of any spec. It only works if you also opt the element into \u003Ccode>display: -webkit-box\u003C\u002Fcode> — a legacy, pre-flexbox box layout model that competed with flexbox and lost, fifteen years ago. You can&#39;t use it on a flex or grid item without fighting your own layout, because \u003Ccode>display: -webkit-box\u003C\u002Fcode> \u003Cem>is\u003C\u002Fem> the display value now, overwriting whatever you actually wanted there.\u003C\u002Fp>",{"id":94,"html":95,"type":84},"b4","\u003Cp>And yet it&#39;s the only reliable way to truncate text after N lines. \u003Ccode>text-overflow: ellipsis\u003C\u002Fcode> — the normal, standard property everyone assumes handles this — only works on a single line of \u003Ccode>white-space: nowrap\u003C\u002Fcode> text. The moment your card description wraps to two or three lines, \u003Ccode>text-overflow\u003C\u002Fcode> has nothing to say about it. There is no standard multi-line equivalent. There never has been.\u003C\u002Fp>",{"id":97,"html":98,"type":84},"b5","\u003Cp>\u003Cstrong>Before you keep reading: have you ever wondered why nobody writes a non-prefixed version of this?\u003C\u002Fstrong> It&#39;s not that browser vendors forgot. It&#39;s that until recently, there wasn&#39;t one to write.\u003C\u002Fp>",{"id":100,"html":101,"text":101,"type":102,"level":31},"b6","The CSS Overflow spec finally caught up","heading",{"id":104,"html":105,"type":84},"b7","\u003Cp>Multi-line truncation is specified now, as a real property: \u003Ccode>line-clamp\u003C\u002Fcode>. No vendor prefix, no \u003Ccode>-webkit-box\u003C\u002Fcode> detour — you set it on a normal block-level element and the browser clips it after the given number of lines, ellipsis included.\u003C\u002Fp>",{"id":107,"code":108,"type":88,"language":61,"highlight":109},"b8",".card-desc {\n  line-clamp: 3;\n}",[],{"id":111,"html":112,"type":84},"b9","\u003Cp>That&#39;s the whole point of standardizing it: you keep whatever \u003Ccode>display\u003C\u002Fcode> you actually need — \u003Ccode>block\u003C\u002Fcode>, \u003Ccode>flex\u003C\u002Fcode>, \u003Ccode>grid\u003C\u002Fcode>, doesn&#39;t matter — instead of being forced into a legacy layout mode just to get an ellipsis.\u003C\u002Fp>",{"id":114,"html":115,"type":84},"b10","\u003Cp>Here&#39;s the part that surprised me enough to write this post: \u003Cstrong>no browser ships the unprefixed \u003Ccode>line-clamp\u003C\u002Fcode> to regular users yet — not in any stable release, anywhere.\u003C\u002Fstrong> Safari&#39;s implementation is the most complete of the three, but it&#39;s only ever lived in Safari Technology Preview — Apple&#39;s experimental, developer-only pre-release channel, not the Safari your actual users run — and WebKit&#39;s own tracking bug for it (&quot;Finish implementing and enable non-prefixed line-clamp&quot;) is still open. (Safari briefly exposed it by accident in the 18.2–18.3 stable releases, then removed it again in 18.4.) Chrome has had a version prototyped behind its experimental-web-platform-features flag since early 2024, with spec and implementation work still ongoing and no public Intent to Ship yet. Firefox gates it behind its own \u003Ccode>layout.css.line-clamp.enabled\u003C\u002Fcode> pref, off by default even in Nightly. Three browsers, three different half-finished attempts, and not one has reached a browser a real visitor is running by default.\u003C\u002Fp>",{"id":117,"html":118,"type":84},"b11","\u003Cp>\u003Cstrong>Guess which browser has gotten the standardized version furthest along, before I told you.\u003C\u002Fstrong> If you guessed Safari, you&#39;re right — just not the way you&#39;d think. &quot;Furthest along&quot; here means &quot;most polished inside an experimental preview channel,&quot; not &quot;shipped to anyone.&quot;\u003C\u002Fp>",{"id":120,"html":121,"text":121,"type":102,"level":31},"b12","So what do you actually ship today",{"id":123,"html":124,"type":84},"b13","\u003Cp>Not \u003Ccode>line-clamp\u003C\u002Fcode> alone — not yet. If you only write the unprefixed property, every browser that doesn&#39;t understand it yet ignores the declaration entirely, your card descriptions render in full, and your card grid layout breaks the moment one product has a three-paragraph description instead of two sentences. The old four-line hack is still the one that works everywhere, so it stays as the baseline, with the new property layered on top for browsers that understand it:\u003C\u002Fp>",{"id":126,"code":127,"type":88,"language":61,"highlight":128},"b14",".card-desc {\n  overflow: hidden;\n  display: -webkit-box;\n  -webkit-box-orient: vertical;\n  -webkit-line-clamp: 3;\n}\n\n@supports (line-clamp: 3) {\n  .card-desc {\n    display: block;\n    line-clamp: 3;\n  }\n}",[],{"id":130,"html":131,"type":84},"b15","\u003Cp>The \u003Ccode>@supports\u003C\u002Fcode> block only applies in browsers that actually understand \u003Ccode>line-clamp\u003C\u002Fcode>, and it explicitly resets \u003Ccode>display\u003C\u002Fcode> back to \u003Ccode>block\u003C\u002Fcode> there — so you get the modern property doing the clamping, on a normal block element, with none of the legacy box-model baggage, in exactly the browsers that support it. Everywhere else, the first block keeps doing the job it&#39;s always done. Nobody has to maintain two copies of the layout.\u003C\u002Fp>",{"id":133,"html":134,"type":84},"b16","\u003C!-- playground:start -->",{"id":136,"html":137,"text":137,"type":102,"level":31},"b17","🎮 Try it yourself",{"id":139,"html":140,"type":84},"b18","\u003Cp>\u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fcss-line-clamp-text-truncation\u002Fplayground\">▶️ Open the interactive playground →\u003C\u002Fa>\u003C\u002Fstrong>\u003C\u002Fp>",{"id":142,"html":143,"type":84},"b19","\u003Cp>\u003Cem>Runs right in your browser — poke at it and watch the concept react live.\u003C\u002Fem>\u003C\u002Fp>",{"id":145,"html":146,"type":84},"b20","\u003C!-- playground:end -->",{"id":148,"html":149,"text":149,"type":102,"level":31},"b21","The thing the hack never told you",{"id":151,"html":152,"type":84},"b22","\u003Cp>The clamp is purely visual. \u003Ccode>overflow: hidden\u003C\u002Fcode> clips the rendered box — it doesn&#39;t delete the trailing sentences from the DOM. Select the card&#39;s text and drag past the ellipsis; the hidden words are still there, still selectable, because nothing was ever removed, only the rendering of the overflow was clipped. If your &quot;show more&quot; button just toggles a class that flips \u003Ccode>-webkit-line-clamp\u003C\u002Fcode> to \u003Ccode>unset\u003C\u002Fcode> or \u003Ccode>line-clamp\u003C\u002Fcode> to \u003Ccode>none\u003C\u002Fcode>, you&#39;re not re-fetching or re-rendering anything — the full text was sitting there the entire time.\u003C\u002Fp>",{"id":154,"html":155,"type":84},"b23","\u003Cp>That&#39;s also why this never substitutes for actually trimming a string server-side if you care about what a screen reader announces, or what gets indexed — the full text is present in the accessibility tree and the page source either way. Truncating for layout and truncating for content are two different problems, and this property only solves the first one.\u003C\u002Fp>",{"id":157,"html":158,"text":158,"type":102,"level":31},"b24","What to actually do with this on Monday",{"id":160,"html":161,"type":84},"b25","\u003Cp>If your team&#39;s truncation mixin still only has the four \u003Ccode>-webkit-\u003C\u002Fcode> lines, you&#39;re not behind — that&#39;s still correct, because it&#39;s still the only version every shipping browser understands, Safari included: its unprefixed implementation hasn&#39;t left Safari Technology Preview. Wrapping it in the \u003Ccode>@supports\u003C\u002Fcode> block above costs you nothing and means the day any browser actually ships \u003Ccode>line-clamp\u003C\u002Fcode> for good, your cards are already using the real property instead of the workaround, with no further changes needed.\u003C\u002Fp>",{"id":163,"html":164,"type":84},"b26","\u003Cp>Next time you paste that four-line incantation into a new component, you&#39;ll at least know what it&#39;s secretly turning your \u003Ccode>display\u003C\u002Fcode> into, and why the standard finally gave it a name. Which other &quot;obviously vendor-only&quot; CSS hack from a decade ago do you think is quietly becoming a real property next?\u003C\u002Fp>",{"id":166,"html":167,"type":84},"b27","\u003C!-- quiz:start -->",{"id":169,"html":170,"text":170,"type":102,"level":31},"b28","🧠 Test yourself",{"id":172,"html":173,"type":84},"b29","\u003Cp>Think it clicked? \u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fcss-line-clamp-text-truncation\u002Fquiz\">Take the 7-question quiz →\u003C\u002Fa>\u003C\u002Fstrong>\u003C\u002Fp>",{"id":175,"html":176,"type":84},"b30","\u003Cp>\u003Cem>Instant feedback, a hint on every question, and an explanation for each answer — right or wrong.\u003C\u002Fem>\u003C\u002Fp>",{"id":178,"html":179,"type":84},"b31","\u003C!-- quiz:end -->",{"id":181,"html":182,"type":84},"b32","\u003C!-- related:start -->",{"id":184,"html":185,"text":185,"type":102,"level":31},"b33","📚 Read next",{"id":187,"type":188,"items":189,"ordered":18},"b34","list",[190,191,192],"\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fcss-text-box-trim-headline-gap\">Stop Fixing Headline Gaps With Negative Margins. Use \u003Ccode>text-box-trim\u003C\u002Fcode>\u003C\u002Fa>","\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fcss-clamp-fluid-typography\">Stop Writing Media Queries for Font Size\u003C\u002Fa>","\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftext-wrap-balance-headline-orphans\">You hand-edit headlines to avoid orphaned words. \u003Ccode>text-wrap: balance\u003C\u002Fcode> does it natively.\u003C\u002Fa>",{"id":194,"html":195,"type":84},"b35","\u003C!-- related:end -->",{"id":197,"type":198},"b36","divider",{"id":200,"html":201,"type":84},"b37","\u003Cp>🚀 \u003Cstrong>Want more like this?\u003C\u002Fstrong> Every guide, playground, and quiz lives on \u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002F\">bestpractic.org\u003C\u002Fa>\u003C\u002Fstrong> — open it and \u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002F\">sign up free\u003C\u002Fa>\u003C\u002Fstrong> so the next one finds you.\u003C\u002Fp>",{"id":203,"html":204,"type":84},"b38","\u003Cp>\u003Cem>Thanks for reading! Let&#39;s stay connected:\u003C\u002Fem>\u003C\u002Fp>",{"id":206,"type":188,"items":207,"ordered":18},"b39",[208,209,210],"⭐ \u003Cstrong>GitHub\u003C\u002Fstrong> — follow me and star the projects: \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fparsajiravand\">github.com\u002Fparsajiravand\u003C\u002Fa>","💬 \u003Cstrong>Discord\u003C\u002Fstrong> — join the frontend best-practices community: \u003Ca href=\"https:\u002F\u002Fdiscord.gg\u002Fd9KRhuAwQ\">discord.gg\u002Fd9KRhuAwQ\u003C\u002Fa>","📸 \u003Cstrong>Instagram\u003C\u002Fstrong> — frontend best practices, daily: \u003Ca href=\"https:\u002F\u002Fwww.instagram.com\u002Fbestpractice___\u002F\">@bestpractice___\u003C\u002Fa>","Open any card grid — a blog's post list, a product catalog, a comment thread — and find the one where the description is cut off after three lines with a neat little `…`. Then view source on the CSS. It's always the same four lines, and I'd bet money whoever wrote them couldn't tell you why all four are required.\n\n```css\n.card-desc {\n  display: -webkit-box;\n  -webkit-box-orient: vertical;\n  -webkit-line-clamp: 3;\n  overflow: hidden;\n}\n```\n\n`-webkit-line-clamp` is a non-standard, vendor-prefixed property that's been in Blink and WebKit since around 2010. It's not part of any spec. It only works if you also opt the element into `display: -webkit-box` — a legacy, pre-flexbox box layout model that competed with flexbox and lost, fifteen years ago. You can't use it on a flex or grid item without fighting your own layout, because `display: -webkit-box` *is* the display value now, overwriting whatever you actually wanted there.\n\nAnd yet it's the only reliable way to truncate text after N lines. `text-overflow: ellipsis` — the normal, standard property everyone assumes handles this — only works on a single line of `white-space: nowrap` text. The moment your card description wraps to two or three lines, `text-overflow` has nothing to say about it. There is no standard multi-line equivalent. There never has been.\n\n**Before you keep reading: have you ever wondered why nobody writes a non-prefixed version of this?** It's not that browser vendors forgot. It's that until recently, there wasn't one to write.\n\n## The CSS Overflow spec finally caught up\n\nMulti-line truncation is specified now, as a real property: `line-clamp`. No vendor prefix, no `-webkit-box` detour — you set it on a normal block-level element and the browser clips it after the given number of lines, ellipsis included.\n\n```css\n.card-desc {\n  line-clamp: 3;\n}\n```\n\nThat's the whole point of standardizing it: you keep whatever `display` you actually need — `block`, `flex`, `grid`, doesn't matter — instead of being forced into a legacy layout mode just to get an ellipsis.\n\nHere's the part that surprised me enough to write this post: **no browser ships the unprefixed `line-clamp` to regular users yet — not in any stable release, anywhere.** Safari's implementation is the most complete of the three, but it's only ever lived in Safari Technology Preview — Apple's experimental, developer-only pre-release channel, not the Safari your actual users run — and WebKit's own tracking bug for it (\"Finish implementing and enable non-prefixed line-clamp\") is still open. (Safari briefly exposed it by accident in the 18.2–18.3 stable releases, then removed it again in 18.4.) Chrome has had a version prototyped behind its experimental-web-platform-features flag since early 2024, with spec and implementation work still ongoing and no public Intent to Ship yet. Firefox gates it behind its own `layout.css.line-clamp.enabled` pref, off by default even in Nightly. Three browsers, three different half-finished attempts, and not one has reached a browser a real visitor is running by default.\n\n**Guess which browser has gotten the standardized version furthest along, before I told you.** If you guessed Safari, you're right — just not the way you'd think. \"Furthest along\" here means \"most polished inside an experimental preview channel,\" not \"shipped to anyone.\"\n\n## So what do you actually ship today\n\nNot `line-clamp` alone — not yet. If you only write the unprefixed property, every browser that doesn't understand it yet ignores the declaration entirely, your card descriptions render in full, and your card grid layout breaks the moment one product has a three-paragraph description instead of two sentences. The old four-line hack is still the one that works everywhere, so it stays as the baseline, with the new property layered on top for browsers that understand it:\n\n```css\n.card-desc {\n  overflow: hidden;\n  display: -webkit-box;\n  -webkit-box-orient: vertical;\n  -webkit-line-clamp: 3;\n}\n\n@supports (line-clamp: 3) {\n  .card-desc {\n    display: block;\n    line-clamp: 3;\n  }\n}\n```\n\nThe `@supports` block only applies in browsers that actually understand `line-clamp`, and it explicitly resets `display` back to `block` there — so you get the modern property doing the clamping, on a normal block element, with none of the legacy box-model baggage, in exactly the browsers that support it. Everywhere else, the first block keeps doing the job it's always done. Nobody has to maintain two copies of the layout.\n\n\u003C!-- playground:start -->\n\n## 🎮 Try it yourself\n\n**[▶️ Open the interactive playground →](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fcss-line-clamp-text-truncation\u002Fplayground)**\n\n_Runs right in your browser — poke at it and watch the concept react live._\n\n\u003C!-- playground:end -->\n\n## The thing the hack never told you\n\nThe clamp is purely visual. `overflow: hidden` clips the rendered box — it doesn't delete the trailing sentences from the DOM. Select the card's text and drag past the ellipsis; the hidden words are still there, still selectable, because nothing was ever removed, only the rendering of the overflow was clipped. If your \"show more\" button just toggles a class that flips `-webkit-line-clamp` to `unset` or `line-clamp` to `none`, you're not re-fetching or re-rendering anything — the full text was sitting there the entire time.\n\nThat's also why this never substitutes for actually trimming a string server-side if you care about what a screen reader announces, or what gets indexed — the full text is present in the accessibility tree and the page source either way. Truncating for layout and truncating for content are two different problems, and this property only solves the first one.\n\n## What to actually do with this on Monday\n\nIf your team's truncation mixin still only has the four `-webkit-` lines, you're not behind — that's still correct, because it's still the only version every shipping browser understands, Safari included: its unprefixed implementation hasn't left Safari Technology Preview. Wrapping it in the `@supports` block above costs you nothing and means the day any browser actually ships `line-clamp` for good, your cards are already using the real property instead of the workaround, with no further changes needed.\n\nNext time you paste that four-line incantation into a new component, you'll at least know what it's secretly turning your `display` into, and why the standard finally gave it a name. Which other \"obviously vendor-only\" CSS hack from a decade ago do you think is quietly becoming a real property next?\n\n\u003C!-- quiz:start -->\n\n## 🧠 Test yourself\n\nThink it clicked? **[Take the 7-question quiz →](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fcss-line-clamp-text-truncation\u002Fquiz)**\n\n_Instant feedback, a hint on every question, and an explanation for each answer — right or wrong._\n\n\u003C!-- quiz:end -->\n\n\u003C!-- related:start -->\n\n## 📚 Read next\n\n- [Stop Fixing Headline Gaps With Negative Margins. Use `text-box-trim`](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fcss-text-box-trim-headline-gap)\n- [Stop Writing Media Queries for Font Size](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fcss-clamp-fluid-typography)\n- [You hand-edit headlines to avoid orphaned words. `text-wrap: balance` does it natively.](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftext-wrap-balance-headline-orphans)\n\n\u003C!-- related:end -->\n\n---\n\n🚀 **Want more like this?** Every guide, playground, and quiz lives on **[bestpractic.org](https:\u002F\u002Fbestpractic.org\u002F)** — open it and **[sign up free](https:\u002F\u002Fbestpractic.org\u002F)** so the next one finds you.\n\n*Thanks for reading! Let's stay connected:*\n\n- ⭐ **GitHub** — follow me and star the projects: [github.com\u002Fparsajiravand](https:\u002F\u002Fgithub.com\u002Fparsajiravand)\n- 💬 **Discord** — join the frontend best-practices community: [discord.gg\u002Fd9KRhuAwQ](https:\u002F\u002Fdiscord.gg\u002Fd9KRhuAwQ)\n- 📸 **Instagram** — frontend best practices, daily: [@bestpractice___](https:\u002F\u002Fwww.instagram.com\u002Fbestpractice___\u002F)",{"title":47,"canonical":213,"description":214},"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fcss-line-clamp-text-truncation","Every card-grid truncation trick runs through the same four lines of `-webkit-line-clamp` CSS that nobody fully understands. The standardized `line-clamp` property exists in the sp","01a21cc5-6e71-7795-8db3-a539149f691f",{"id":217,"locked":18},"01a21cc5-6e91-7274-b5ee-b272edc208ad",[219],{"id":220,"slug":46,"title":221,"_count":222},"01a21cc5-6ea9-709d-8fd5-6b1e130320ff","Test yourself — line-clamp",{"questions":223},7,[225],{"locale":13,"slug":46},{"id":220,"slug":46,"title":221,"_count":227,"questionCount":223},{"questions":223},[229,231,235,237,239,241,245,249,253,257,261,265],{"slug":67,"name":68,"articles":230},200,{"slug":232,"name":233,"articles":234},"javascript","Javascript",158,{"slug":70,"name":71,"articles":236},105,{"slug":73,"name":74,"articles":238},90,{"slug":61,"name":65,"articles":240},58,{"slug":242,"name":243,"articles":244},"typescript","Typescript",37,{"slug":246,"name":247,"articles":248},"performance","Performance",34,{"slug":250,"name":251,"articles":252},"programming","Programming",26,{"slug":254,"name":255,"articles":256},"react","React",23,{"slug":258,"name":259,"articles":260},"node","Node",19,{"slug":262,"name":263,"articles":264},"browser","Browser",18,{"slug":266,"name":267,"articles":268},"nextjs","Nextjs",14,[],{"items":271,"meta":392},[272,283,301,319,337,355,373],{"id":45,"slug":46,"title":47,"subtitle":48,"excerpt":49,"coverUrl":50,"locale":13,"readingMinutes":51,"publishedAt":52,"viewCount":53,"likeCount":19,"commentCount":19,"author":273,"vertical":274,"topic":275,"tags":276,"_count":281,"playground":282,"hasQuiz":17,"hasPlayground":17},{"id":55,"name":56,"username":57,"avatarUrl":48,"headline":58},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":61,"name":62},[277,278,279,280],{"slug":61,"name":65,"color":48},{"slug":67,"name":68,"color":48},{"slug":70,"name":71,"color":48},{"slug":73,"name":74,"color":48},{"assessments":76},{"slug":46},{"id":284,"slug":285,"title":286,"subtitle":48,"excerpt":287,"coverUrl":288,"locale":13,"readingMinutes":51,"publishedAt":289,"viewCount":290,"likeCount":19,"commentCount":19,"author":291,"vertical":292,"topic":293,"tags":294,"_count":299,"playground":300,"hasQuiz":17,"hasPlayground":17},"01a21cc5-8175-722c-b0a2-f4c1db300af5","css-mask-image-scroll-fade-edges","CSS mask-image Explained: Fade Edges Without Gradient Divs","Horizontally scrolling chip lists and tab bars usually hint 'there's more to scroll' with an absolutely positioned gradient div glued to each edge. It works on a solid background and falls apart on anything else. mask-image fades the actual content, not a fake overlay.","\u002Fmedia\u002Fcovers\u002Fcss-mask-image-scroll-fade-edges.png","2026-12-02T01:45:45.100Z",64,{"id":55,"name":56,"username":57,"avatarUrl":48,"headline":58},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":61,"name":62},[295,296,297,298],{"slug":61,"name":65,"color":48},{"slug":70,"name":71,"color":48},{"slug":67,"name":68,"color":48},{"slug":73,"name":74,"color":48},{"assessments":76},{"slug":285},{"id":302,"slug":303,"title":304,"subtitle":48,"excerpt":305,"coverUrl":306,"locale":13,"readingMinutes":53,"publishedAt":307,"viewCount":308,"likeCount":19,"commentCount":19,"author":309,"vertical":310,"topic":311,"tags":312,"_count":317,"playground":318,"hasQuiz":17,"hasPlayground":17},"01a1fce0-c3d4-737b-8a48-5669d1350ff2","css-transition-behavior-allow-discrete","CSS Transitions Skip display: none. transition-behavior Fixes That.","You can finally animate a dialog in from display: none without JavaScript — transition-behavior and @starting-style turn the jump-cut into a real transition.","\u002Fmedia\u002Fcovers\u002Fcss-transition-behavior-allow-discrete.png","2026-11-27T11:46:28.711Z",194,{"id":55,"name":56,"username":57,"avatarUrl":48,"headline":58},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":61,"name":62},[313,314,315,316],{"slug":61,"name":65,"color":48},{"slug":67,"name":68,"color":48},{"slug":70,"name":71,"color":48},{"slug":73,"name":74,"color":48},{"assessments":76},{"slug":303},{"id":320,"slug":321,"title":322,"subtitle":48,"excerpt":323,"coverUrl":324,"locale":13,"readingMinutes":53,"publishedAt":325,"viewCount":326,"likeCount":19,"commentCount":19,"author":327,"vertical":328,"topic":329,"tags":330,"_count":335,"playground":336,"hasQuiz":17,"hasPlayground":17},"01a1df1b-24b4-759b-be78-50479b1bfe26","scrollbar-color-native-scrollbar-styling","I Deleted My Scrollbar Hacks. `scrollbar-color` Replaced Them.","A dashboard's scrollbar matched Figma in Chrome and looked broken in Firefox. scrollbar-color and scrollbar-width fix that with two lines of standard CSS — no vendor prefixes, no UA sniffing.","\u002Fmedia\u002Fcovers\u002Fscrollbar-color-native-scrollbar-styling.png","2026-11-27T11:42:54.989Z",155,{"id":55,"name":56,"username":57,"avatarUrl":48,"headline":58},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":61,"name":62},[331,332,333,334],{"slug":61,"name":65,"color":48},{"slug":67,"name":68,"color":48},{"slug":70,"name":71,"color":48},{"slug":73,"name":74,"color":48},{"assessments":76},{"slug":321},{"id":338,"slug":339,"title":340,"subtitle":48,"excerpt":341,"coverUrl":342,"locale":13,"readingMinutes":51,"publishedAt":343,"viewCount":344,"likeCount":19,"commentCount":19,"author":345,"vertical":346,"topic":347,"tags":348,"_count":353,"playground":354,"hasQuiz":17,"hasPlayground":17},"01a1df1b-36a8-772a-9e7a-3586a0ebff65","css-scroll-margin-top-anchor-offset","Your Sticky Header Is Hiding Anchor Links. `scroll-margin-top` Fixes It.","Clicking a table-of-contents link lands the heading right behind your sticky nav, half-hidden. The fix isn't a JavaScript scroll offset — it's one CSS property the browser already checks before it scrolls.","\u002Fmedia\u002Fcovers\u002Fcss-scroll-margin-top-anchor-offset.png","2026-11-21T06:52:41.283Z",358,{"id":55,"name":56,"username":57,"avatarUrl":48,"headline":58},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":61,"name":62},[349,350,351,352],{"slug":61,"name":65,"color":48},{"slug":67,"name":68,"color":48},{"slug":70,"name":71,"color":48},{"slug":73,"name":74,"color":48},{"assessments":76},{"slug":339},{"id":356,"slug":357,"title":358,"subtitle":48,"excerpt":359,"coverUrl":360,"locale":13,"readingMinutes":53,"publishedAt":361,"viewCount":362,"likeCount":19,"commentCount":19,"author":363,"vertical":364,"topic":365,"tags":366,"_count":371,"playground":372,"hasQuiz":17,"hasPlayground":17},"01a1af7a-c595-77be-8e0a-dea27ce0db13","variable-fonts-one-file-many-weights","I Was Shipping Five Font Files. One Variable Font Replaced Them All.","Regular, Medium, Semibold, Bold, Bold Italic — five @font-face blocks, five network requests, just to render a design system's type scale. A single variable font file replaces all of them, and it's been supported everywhere since 2018.","\u002Fmedia\u002Fcovers\u002Fvariable-fonts-one-file-many-weights.png","2026-11-15T12:10:51.143Z",461,{"id":55,"name":56,"username":57,"avatarUrl":48,"headline":58},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":61,"name":62},[367,368,369,370],{"slug":61,"name":65,"color":48},{"slug":67,"name":68,"color":48},{"slug":70,"name":71,"color":48},{"slug":246,"name":247,"color":48},{"assessments":76},{"slug":357},{"id":374,"slug":375,"title":376,"subtitle":48,"excerpt":377,"coverUrl":378,"locale":13,"readingMinutes":379,"publishedAt":380,"viewCount":381,"likeCount":19,"commentCount":19,"author":382,"vertical":383,"topic":384,"tags":385,"_count":390,"playground":391,"hasQuiz":17,"hasPlayground":17},"01a1c0f9-dcbd-71ce-acad-1012bf44027c","overflow-clip-vs-overflow-hidden-sticky","overflow: hidden breaks position: sticky. overflow: clip doesn't.","A sticky header that worked in isolation stops sticking the moment it's dropped inside a rounded-corner card with overflow: hidden. The card isn't scrollable — but the browser doesn't care. overflow: clip is the fix, and it's been quietly ready for a while.","\u002Fmedia\u002Fcovers\u002Foverflow-clip-vs-overflow-hidden-sticky.png",4,"2026-11-15T12:07:47.081Z",372,{"id":55,"name":56,"username":57,"avatarUrl":48,"headline":58},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":61,"name":62},[386,387,388,389],{"slug":61,"name":65,"color":48},{"slug":67,"name":68,"color":48},{"slug":70,"name":71,"color":48},{"slug":73,"name":74,"color":48},{"assessments":76},{"slug":375},{"page":76,"perPage":223,"total":240,"totalPages":393},9,"\u003Cdiv class=\"shj shj-lang-css shj-multiline\" data-lang=\"css\">\u003Cdiv class=\"shj-scroll\">\u003Cdiv class=\"shj-numbers\">\u003Cdiv>1\u003C\u002Fdiv>\u003Cdiv>2\u003C\u002Fdiv>\u003Cdiv>3\u003C\u002Fdiv>\u003Cdiv>4\u003C\u002Fdiv>\u003Cdiv>5\u003C\u002Fdiv>\u003Cdiv>6\u003C\u002Fdiv>\u003C\u002Fdiv>\u003Cdiv class=\"shj-code\">\u003Cspan class=\"shj-var\">.card-desc\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan>\n  \u003Cspan class=\"shj-var\">display\u003C\u002Fspan>: -\u003Cspan class=\"shj-num\">webkit-box\u003C\u002Fspan>;\n  -\u003Cspan class=\"shj-var\">webkit-box-orient\u003C\u002Fspan>: \u003Cspan class=\"shj-num\">vertical\u003C\u002Fspan>;\n  -\u003Cspan class=\"shj-var\">webkit-line-clamp\u003C\u002Fspan>: \u003Cspan class=\"shj-num\">3\u003C\u002Fspan>;\n  \u003Cspan class=\"shj-var\">overflow\u003C\u002Fspan>: \u003Cspan class=\"shj-num\">hidden\u003C\u002Fspan>;\n\u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\u003C\u002Fdiv>\u003C\u002Fdiv>\u003C\u002Fdiv>","\u003Cdiv class=\"shj shj-lang-css shj-multiline\" data-lang=\"css\">\u003Cdiv class=\"shj-scroll\">\u003Cdiv class=\"shj-numbers\">\u003Cdiv>1\u003C\u002Fdiv>\u003Cdiv>2\u003C\u002Fdiv>\u003Cdiv>3\u003C\u002Fdiv>\u003C\u002Fdiv>\u003Cdiv class=\"shj-code\">\u003Cspan class=\"shj-var\">.card-desc\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan>\n  \u003Cspan class=\"shj-var\">line-clamp\u003C\u002Fspan>: \u003Cspan class=\"shj-num\">3\u003C\u002Fspan>;\n\u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\u003C\u002Fdiv>\u003C\u002Fdiv>\u003C\u002Fdiv>","\u003Cdiv class=\"shj shj-lang-css shj-multiline\" data-lang=\"css\">\u003Cdiv class=\"shj-scroll\">\u003Cdiv class=\"shj-numbers\">\u003Cdiv>1\u003C\u002Fdiv>\u003Cdiv>2\u003C\u002Fdiv>\u003Cdiv>3\u003C\u002Fdiv>\u003Cdiv>4\u003C\u002Fdiv>\u003Cdiv>5\u003C\u002Fdiv>\u003Cdiv>6\u003C\u002Fdiv>\u003Cdiv>7\u003C\u002Fdiv>\u003Cdiv>8\u003C\u002Fdiv>\u003Cdiv>9\u003C\u002Fdiv>\u003Cdiv>10\u003C\u002Fdiv>\u003Cdiv>11\u003C\u002Fdiv>\u003Cdiv>12\u003C\u002Fdiv>\u003Cdiv>13\u003C\u002Fdiv>\u003C\u002Fdiv>\u003Cdiv class=\"shj-code\">\u003Cspan class=\"shj-var\">.card-desc\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan>\n  \u003Cspan class=\"shj-var\">overflow\u003C\u002Fspan>: \u003Cspan class=\"shj-num\">hidden\u003C\u002Fspan>;\n  \u003Cspan class=\"shj-var\">display\u003C\u002Fspan>: -\u003Cspan class=\"shj-num\">webkit-box\u003C\u002Fspan>;\n  -\u003Cspan class=\"shj-var\">webkit-box-orient\u003C\u002Fspan>: \u003Cspan class=\"shj-num\">vertical\u003C\u002Fspan>;\n  -\u003Cspan class=\"shj-var\">webkit-line-clamp\u003C\u002Fspan>: \u003Cspan class=\"shj-num\">3\u003C\u002Fspan>;\n\u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\n\n\u003Cspan class=\"shj-kwd\">@supports\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-kwd\">line-clamp\u003C\u002Fspan>: \u003Cspan class=\"shj-num\">3\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan>\n  \u003Cspan class=\"shj-var\">.card-desc\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan>\n    \u003Cspan class=\"shj-var\">display\u003C\u002Fspan>: \u003Cspan class=\"shj-num\">block\u003C\u002Fspan>;\n    \u003Cspan class=\"shj-var\">line-clamp\u003C\u002Fspan>: \u003Cspan class=\"shj-num\">3\u003C\u002Fspan>;\n  \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\n\u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\u003C\u002Fdiv>\u003C\u002Fdiv>\u003C\u002Fdiv>",{"locked":18,"total":19,"comments":398},[]]