Performance: After pseudo-element
This affects the rendering performance by adding extra elements to the DOM visually without increasing DOM nodes, impacting paint and composite stages.
Jump into concepts and practice - no test required
div::after { content: ''; display: block; width: 100%; height: 10px; background: red; position: relative; margin-top: 10px; }
div::after { content: ''; display: block; width: 100%; height: 10px; background: red; position: absolute; top: 100%; left: 0; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using :after with absolute positioning | 0 (no new DOM nodes) | 1+ if layout changes | medium due to paint and composite | [!] OK |
| Using :after with relative positioning and margin | 0 | 0 | low paint cost | [OK] Good |
::after pseudo-element do?::after::after pseudo-element inserts content after the selected element in the page layout without modifying the HTML structure.::after.::after adds content after element [OK]::after to add a red asterisk after a paragraph?::after, not :after.content, and color is set with color. Options C and D use incorrect properties (text and font-color).::after with content and color [OK]h1::after { content: ' [check]'; color: green; }Given HTML: <h1>Task Complete</h1>
::after content insertion::after adds the string ' [check]' after the h1 text, so the check mark appears after "Task Complete".::after adds green check after text [OK]div::after { content: foo; }contentcontent property requires a string (in quotes), url(), or special keywords like '' (empty string). The value foo is invalid here.::after on div::after pseudo-element can be used on any element, including div.content must be a string or url, not 'foo' -> Option Dcontent needs string or url, not 'foo' [OK]::aftercontent: '"' adds the quote mark after blockquote text visually.::after is not part of the DOM accessibility tree and is ignored by screen readers, so no additional CSS properties are needed.aria-hidden (ARIA attributes belong on HTML elements). blockquote::after { content: '"'; font-size: 2rem; color: gray; display: none; } uses display: none; which hides the quote visually. blockquote::after { content: '"'; font-size: 2rem; color: gray; role: presentation; } uses invalid CSS property role.