Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

leading vs line-height in CSS

Tags:

css

So in traditional page layout programs, when you do leading, it doesn't effect the first line of a paragraph. However, if you use line-height in CSS, whatever your number is, that will effect the first line. Is there any way to mimic desktop leading in CSS? Basically, I want to only have line-height apply to the subsequent lines, not the first line.

like image 599
Matt Brown Avatar asked Nov 26 '25 19:11

Matt Brown


1 Answers

You could try something like:

.class {
    line-height: 1.5;
}
.class::first-line {
    line-height: 1;
}

/* If legacy browsers must be supported */
.class:first-line { 
    line-height: 1;
}

https://developer.mozilla.org/en-US/docs/CSS/::first-line

http://reference.sitepoint.com/css/pseudoelement-firstline

like image 138
Ryan Avatar answered Nov 28 '25 17:11

Ryan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!