
Pseudo-Elements
The Secret Tricks of CSS Wizards
In the dim, shadowy corners of CSS, pseudo-elements dwell like invisible magicians, quietly casting their spells without ever being seen. While ordinary HTML elements dutifully follow instructions, pseudo-elements appear when you need something extraordinary.
They materialize out of thin air, adding weight to the first letter of a paragraph, conjuring content before or after an element, or transforming list bullets into magical symbols. These subtle yet powerful spells elevate your design from “nice” to “wow!” They work seamlessly behind the scenes, adding depth and flair to your creations without complicating the HTML structure.
Pseudo-Elements – More Than Meets the Eye
Decorate text or target the first letter with style!

::first-letter
The Beginning of Every Tale
The ::first-letter spell brings special attention to the first letter of your text. You can make it bigger, bolder, or transform it into a majestic character straight out of ancient manuscripts. It’s the perfect way to pull readers into the story. With ::first-letter, a simple beginning becomes an epic event!
p::first-letter {
font-size: 2em;
}
This CSS enlarges the first letter of each paragraph to twice the font size (2em) and visually emphasizes it.

::first-line
The Prologue of the First Line
With ::first-line, you can add a magical touch to the opening line of any text block. This pseudo-element grabs the first line and enchants it with colors, font sizes, or even a unique background. It’s like the introductory chant of a wizard.
p::first-line {
font-weight: bold;
color: brown
}
This CSS styles the first line of each paragraph bold and brown.

::before
The Harbinger of Content
::before acts as a loyal herald, standing before your element like a messenger that appears just before the main content. It allows you to add content that doesn’t exist in the HTML, making it seem as if it was always there.
h1::before {
content: "★ ";
}
This CSS adds a star symbol before each <h1> element to visually enhance the title.

::after
The Final Flourish
If ::before is the herald, then ::after is the encore that lingers after the grand finale. It lets content appear after the main text, as if a narrator adds one final note to leave a lasting impression.
h1::after {
content: " ★";
}
This CSS appends a star symbol after each <h1> element’s content to visually round off the title.

::marker
The List Mark Enchanter
With ::marker, you can take control of list markers. Why settle for ordinary dots or dashes when you can turn them into glowing symbols or enchanting colors? Transform mundane list points into something extraordinary.
ul li::marker {
color: green;
content: "→";
}
This CSS makes list markers green and replaces them with arrows.

::selection
The Flickering Magic of Highlights
When someone selects text on your page, it should feel magical. ::selection lets you enchant the highlighted area, making it shine with vibrant colors when a user drags their mouse over it. No more dull gray—just bold, dazzling brilliance! With ::selection, even the act of selecting text becomes an illuminating experience!
::selection {
background: green;
color: black;
}
Selected text is given a green background and black font color.