[CSS Selector] E:after
Using 'selector:after', you can generate the last child element of an element. This is commonly called the ':after pseudo-element'. It does not work in IE7 or earlier.
When generating a ':after pseudo-element', the 'content' property is required. Without a 'content' property, the ':after pseudo-element' will not be generated. If you want to generate a ':after pseudo-element' without any text content, pass an empty string to the 'content' property.
Sample Code
div:after { content: "Hello World";} /* Generates a ':after pseudo-element' containing the text "Hello World". */
p:after {} /* No 'content' property is specified, so the ':after pseudo-element' is not generated. */
div.div1:after { content: ""; display: block; height: 10px; background-color: red;} /* To output no text, pass an empty string like this. */
Browser Result
div:after { content: "Hello World";} /* Generates a ':after pseudo-element' containing the text "Hello World". */
p:after {} /* No 'content' property is specified, so the ':after pseudo-element' is not generated. */
div.div1:after { content: ""; display: block; height: 10px; background-color: red;} /* To output no text, pass an empty string like this. */
<div> The ':after pseudo-element' is being generated.</div> <p>The ':after pseudo-element' is not generated because the 'content' property is not specified.</p> <div class="div1">A red line is being generated using the ':after pseudo-element'.</div>
The default 'display' property value of the ':after pseudo-element' is 'inline'.
Note that the ':after pseudo-element' is generated not after the specified element, but at the position of the last child element inside the specified element.
<p> <!-- The ':after pseudo-element' is generated around here. --> </p> <!-- Not here -->
Browser Support
3 and earlier ×
8 △
7 ×
6 ×
6 △
5 △
4 △
3 and earlier ×
2 and earlier ×
Android Browser
4.4+ ○
3 and earlier ×* Version information is based on MDN.
If you find any errors or copyright issues, please contact us.