-webkit-line-clamp
Quick Summary for -webkit-line-clamp
The -webkit-line-clamp CSS property allows limiting of the contents of a block container to the specified number of lines.
Code Usage for -webkit-line-clamp

<pre class="brush: css notranslate"><code><span class="token comment">/ Keyword value /</span> <span class="token property">-webkit-line-clamp</span><span class="token punctuation">:</span> none<span class="token punctuation">;</span> <span class="token comment">/ &lt;integer&gt; values /</span> <span class="token property">-webkit-line-clamp</span><span class="token punctuation">:</span> 3<span class="token punctuation">;</span> <span class="token property">-webkit-line-clamp</span><span class="token punctuation">:</span> 10<span class="token punctuation">;</span> <span class="token comment">/ Global values /</span> <span class="token property">-webkit-line-clamp</span><span class="token punctuation">:</span> inherit<span class="token punctuation">;</span> <span class="token property">-webkit-line-clamp</span><span class="token punctuation">:</span> initial<span class="token punctuation">;</span> <span class="token property">-webkit-line-clamp</span><span class="token punctuation">:</span> unset<span class="token punctuation">;</span> </code></pre>

More Details for -webkit-line-clamp

-webkit-line-clamp

The -webkit-line-clamp CSS property allows limiting of the contents of a block container to the specified number of lines.

It only works in combination with the display property set to -webkit-box or -webkit-inline-box and the -webkit-box-orient property set to vertical.

In most cases you will also want to set overflow to hidden, otherwise the contents won't be clipped but an ellipsis will still be shown after the specified number of lines.

When applied to anchor elements, the truncating can happen in the middle of the text, not necessarily at the end.

Note: This property was originally implemented in WebKit and has some issues. It got standardized for legacy support. The CSS Overflow Module Level 3 specification also defines a line-clamp property, which is meant to replace this property and avoid its issues.

Syntax

/* Keyword value */ -webkit-line-clamp: none;  /* <integer> values */ -webkit-line-clamp: 3; -webkit-line-clamp: 10;  /* Global values */ -webkit-line-clamp: inherit; -webkit-line-clamp: initial; -webkit-line-clamp: unset; 
none

This value specifies that the content won't be clamped.

<integer>

This value specifies the number of lines after which the content will be clamped. It must be greater than 0.

Formal definition

Initial valuenone
Applies toall elements
Inheritedno
Computed valueas specified
Animation typeby computed value type

Formal syntax

none | <integer>

Examples

Truncating a paragraph

HTML
<p>   In this example the <code>-webkit-line-clamp</code> property is set to <code>3</code>, which means the text is clamped after three lines.   An ellipsis will be shown at the point where the text is clamped. </p> 
CSS
p {   width: 300px;   display: -webkit-box;   -webkit-box-orient: vertical;   -webkit-line-clamp: 3;   overflow: hidden; } 
Result

Specifications

Specification
CSS Overflow Module Level 3 # webkit-line-clamp

See also

Line Clampin' (Truncating Multiple Line Text) line-clamp

No Items Found.

Add Comment
Type in a Nick Name here
 
Other Categories in CSS
css
Search CSS
Search CSS by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

You could also follow me on twitter. I have a couple of youtube channels if you want to see some video related content. RuneScape 3, Minecraft and also a coding channel here Web Dev.

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
1. Show your work to the world instead of keeping in your head💆. 2. Do the work consistently👌 3. Respect your work🥰 4. Don't postpone your work 5. Make mistakes 🔥🔥🔥
Unknown
Latest News
## 🚀 AI Giants Hit Bullseye: Anthropic & OpenAI Achieve Product-Market Fit Anthropic and OpenAI have reached a significant milestone, finding product-market fit with their AI technologies, which means their products effectively meet the needs of their customers, driving growth and adoption. This achievement showcases the practical value of their innovations, enabling businesses and individuals to leverage AI for enhanced productivity and efficiency. With this alignment of product and market needs, these companies are poised to transform industries and shape the future of technology.