CSS Pseudo Element Decorations
Create decorative elements using CSS pseudo-elements with content and positioning for tooltips badges and icons.
Code
.tooltip::after {
content: attr(data-tooltip);
position: absolute;
bottom: 100%;
background: #1a1a2e;
color: white;
padding: 4px 8px;
border-radius: 4px;
white-space: nowrap;
}CSS Pseudo Element Decorations
Create decorative elements using CSS pseudo-elements with content and positioning for tooltips badges and icons.
Code
.tooltip::after {
content: attr(data-tooltip);
position: absolute;
bottom: 100%;
background: #1a1a2e;
color: white;
padding: 4px 8px;
border-radius: 4px;
white-space: nowrap;
}
Explanation
::before and ::after inject decorative content (a tooltip arrow, a badge) without extra DOM nodes. Expected behavior: the generated box participates in layout like a real child element. Constraint: the content property must be set for the pseudo-element to render, and pseudo-elements are decorative only — they are not exposed to assistive technology.
Interactive Tools for This Topic
Aspect Ratio CalculatorSimplify a width-to-height ratio, show its decimal value, and derive a matching height for a new width.Border Radius PreviewPreview four-corner border-radius values on a live box and copy the generated shorthand border-radius CSS declaration.Box Shadow GeneratorBuild CSS box-shadow values with offset, blur, spread, color, opacity, and inset controls, with a live preview of the result.CSS Color Name LookupTranslate between CSS keyword color names and hex values with RGB and HSL conversions, exact name matching, and nearest-color suggestions.
Report a problem with this exampleOpens a pre-filled issue on GitHub.