0% completed
The content property is used with CSS pseudo-elements to insert text or other content into the document. When you use this property along with ::before
or ::after
, you can add extra content without changing your HTML. This helps you add decorative elements, icons, or labels with only CSS.
selector::before { content: "Text here"; /* Inserts text before the element */ } selector::after { content: "Text here"; /* Inserts text after the element */ }
Explanation:
::before
and ::after
).In this example, we insert the word "Note:" before a paragraph. This shows how to use the content property to add text without modifying the HTML.
Explanation:
::before
):
In this example, we add a decorative star icon after a heading using a Unicode character. This demonstrates another use of the content property to enrich the design.
Explanation:
::after
):
\2605
) is added after the heading "Featured Article".These examples show how the content property works with pseudo-elements to add extra text or symbols to your page. This technique lets you enrich your design without changing the HTML, keeping your structure clean and your style flexible.
.....
.....
.....