CSS ::after
Pseudo-Element
The ::after
pseudo-element allows you to insert content after an element without modifying the HTML.
1. Basic Usage
✅ Adding Text After an Element
✅ Adds a fire emoji after every <p>
element.
2. Adding Icons or Symbols
✅ Adds a right arrow after every <button>
.
3. Styling with CSS
You can style the ::after
content just like any other element.
✅ Creates a blue line under every <h1>
.
4. Using ::after
for Decorative Effects
✅ Underline Effect
✅ The underline shrinks on hover.
5. Creating Tooltips with ::after
✅ Shows a tooltip when hovering.
6. When to Use ::after
?
✔ Add decorative elements
✔ Enhance UI without extra HTML
✔ Create tooltips, icons, or effects