How to capitalize first line with CSS? ::first-line pseudo-element not working

user1390754 picture user1390754 · Aug 4, 2012 · Viewed 12.3k times · Source

Right now I've got a paragraph and I'd like to capitalize the entire first line. I've set the first paragraph to an ID "firstp" and tried:

#firstp::first-line {
  text-transform: uppercase;
}

I've tried it with text-transform: capitalize but that doesn't work either. It's strange because I've managed to change the first letter (changed font size) using #firstp:first-letter.

Answer

Saurabh Kumar picture Saurabh Kumar · Aug 4, 2012

text-transform on :first-line is really buggy right now, see the reference here http://reference.sitepoint.com/css/text-transform

You can use this jquery plugin called linify https://github.com/octopi/Linify to select the first line and then apply the property of text-transform: uppercase

Regards,