:first-line and :first-letter

Supported by Explorer 5 on Mac, Explorer 5.5 and 6 on Windows, Opera 5, Safari, Konqueror 2.1 and lower and Mozilla.

Safari doesn't support my extra test p:first-letter, though it does support the generic p.intro:first-letter which I define in my general style sheet.

Explorer 6 in Strict mode requires a space between the selector and the opening bracket {. See the IE 6 pseudo elements bug page for more information.

The psuedo-classes :first-line and first-letter are for giving special styles to the first line and letter of an HTML element.

The first line is determined by the browser as the real first line of the paragraph on the screen. So if you resize your browser window the first line will become longer or shorter. The styles will be applied to this longer or shorter first line.


p:first-letter {text-decoration: underline;}
p:first-line {font-style: italic;}