::before
W3C CSS Snapshot 2026
Insert decorative generated content at the start of an element’s content.
On this page
Syntax and values
| Value or syntax | What it does |
|---|---|
.notice::before | Use content to create the pseudo-element. Keep essential text in the HTML. |
Try the example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>::before</title>
<style>
.notice::before { content: "◆ "; color: teal; }
</style>
</head>
<body>
<p class="notice">Registration opens Monday.</p>
<p id="location">Meet in Room 2.</p>
<h2>Workshop</h2>
</body>
</html>
What to expect A teal diamond appears before the notice text.