5 out of 7 rated this helpful - Rate this topic

::after pseudo-element

Defines generated content that appears after an element.

CSS 2.1, Section 5.12.3Internet Explorer 8

Syntax

sel::after {...}

Parameters

sel

A simple selector.

Standards information

Remarks

The ::before and ::after pseudo-elements specify the location of content before and after an element in the document tree. The content attribute, in conjunction with these pseudo-elements, specifies what is inserted.

The generated content interacts with other boxes as if they were real elements inserted just inside their associated element. The content box of the associated element expands to include the generated content, if necessary. Other specified styling properties apply to the appearance of the inserted content, not to the element's content.

In Windows Internet Explorer 8, as well as later versions of Windows Internet Explorer in IE8 Standards mode, only the one-colon form of this pseudo-element is recognized—that is, :after.

Beginning with Windows Internet Explorer 9, the ::after pseudo-element requires two colons, though the one-colon form is still recognized and behaves identically to the two-colon form. Microsoft and the World Wide Web Consortium (W3C) encourage web authors to use the two-colon form of the ::after pseudo-element. For more information, see the Pseudo-elements section of the W3C's CSS3 Selectors specification.

Examples

The following style rules insert curly braces before and after each occurrence of h1 in the document tree. The curly braces will be displayed in brown on a light blue background; the element itself will remain unchanged.


h1::before {
  content: "{ ";
  color: brown;
  background: lightblue;
}
h1::after {
  content: " }";
  color: brown;
  background: lightblue;
}  

See also

content

 

 

Send comments about this topic to Microsoft

Build date: 11/29/2012

Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.