::first-line

Applies one or more styles to the first line of the object.

Syntax

::first-line { sRules }

Possible values

sRules

Value that specifies one or more cascading style sheets attribute/value pairs.

Remarks

The ::first-line pseudo-class matches an element that is the first child element of some other element.

Inline text is not considered to be part of the document tree, and is not counted when calculating the first child. For example, the em element is the first child of the p element in the following HTML code:

<p>abc <em>default</em> def</p>

Examples

In the following example, the selector matches any p element that is the first child of its parent (the style rule suppresses indentation for the first paragraph only):

<style>
    p:first-child {text-indent: 0}
</style> 

The preceding selector would match the p element inside the div of the first fragment that follows, but would not match the p element in the second fragment:

<!-- First fragment -->
<div class="note">
   <p> The first P inside the note. </p>
</div>

<!-- Second fragment -->
<div class="note">
   <h2>Note</h2>
   <p> The first P inside the note. </p>
</div>

Standards Information

This pseudo-class is defined in CSS Selectors Level 3 Gg721786.xtlink_newWindow(en-us,Expression.40).png.

Applies to

a, abbr, acronym, address, b, big, blockquote, body, caption, center, cite, code, col, colgroup, dd, dfn, dir, div, dl, dt, em, form, hn, html, i, img, input, input type=button, input type=checkbox, input type=file, input type=hidden, input type=image, input type=password, input type=radio, input type=reset, input type=submit, input type=text, kbd, label, legend, li, listing, marquee, menu, ol, p, plaintext, pre, s, samp, select, small, span, strike, strong, sub, sup, table, tbody, td, textarea, tfoot, th, thead, tr, tt, u, ul, var, xmp

See also

Concepts

::after
::before
::selection
::first-letter

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.