andrelange91
andrelange91

Reputation: 1148

line-height on text with minimum 2 lines of text

is there a way for me to add line-hight:22px; to any texts that has two lines or more. but not affect text that does not go onto a second line ?

Is there a way to achive this in css only ?

Upvotes: 9

Views: 5694

Answers (1)

user7236046
user7236046

Reputation:

You can with pure CSS, but beware of IE8 and below. Here is the browser support.

.class {
    line-height: 22px;
}

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

What this does it set everything to a line-height of 22px, but resets the first line to a line-height of 1, you could also use 100% etc. That should do what you're wanting to achieve.

Upvotes: 14

Related Questions