What is Unicode?
Unicode is the worldwide standard for text on computers. It gives every character, from every writing system, a unique number called a code point. Code points are written as U+ followed by a hexadecimal (base 16) number. For example:
U+0041is the capital letter AU+2022is a bullet: β’U+2713is a tick: βU+1F600is a grinning face emoji: π
Unicode covers over 150,000 characters, including letters, punctuation, arrows, maths symbols, shapes and emoji. That makes it a handy source of small icons and decorations you can add with CSS alone, without any image files.
Three ways to write the same character
Each language on the web has its own way of writing a character by its code point:
| Where | Syntax | Example for β’ |
|---|---|---|
| HTML | &#x + hex + ; | • (or the named entity •) |
| CSS | \ + hex | "\2022" |
| JavaScript | \u + hex | "\u2022" or "\u{2022}" |
Mixing these up is a common mistake: • won't work in CSS, and \2022 won't work in HTML.
Tip: to look up the code point and the ready-made HTML and CSS codes for any character, visit CharacterCodes.net.
Can I just type the character?
Yes. As long as your files are saved as UTF-8 (the standard encoding, and the default in modern code editors) and your page declares <meta charset="utf-8">, you can paste characters straight into your CSS:
.note::before {
content: "β’";
}
Escapes like "\2022" are still useful, though. They survive copying and pasting between tools that might mangle special characters, and they make invisible characters, such as a non-breaking space (\00A0), visible in your code. The examples in this post use escapes, so you can see exactly which character is being used.
Adding characters with the content property
The usual way to add a Unicode character with CSS is the content property on a ::before or ::after pseudo-element (an extra, styleable piece of an element that CSS creates for you):
.note::before {
content: "\2022"; /* bullet */
margin-right: 8px;
color: #2563eb;
}
Unicode characters can be added with CSS alone.
Because the character is text, you can style it with any text properties: color, font-size, font-weight and so on.
The escape gotcha
A CSS escape is a backslash followed by up to six hexadecimal digits. The browser keeps reading digits until it hits something that isn't one, so if the next character in your string happens to be a valid hex digit (0β9 or AβF), it becomes part of the code point by mistake.
To end an escape, either add a single space (which the browser removes) or write all six digits, padded with zeros. The dashed boxes below show what each version actually displays:
"\2192A"
"\2192 A"
"\2192 A"
"\002192A"
"\2192A"is read as code pointU+2192A, a completely different character (a Chinese character, if your device has a font for it)."\2192 A"ends the escape with a space, but that space is removed, so the arrow and the A touch."\2192 A"uses two spaces: one to end the escape and one that's actually displayed."\002192A"uses all six digits, so the escape ends automatically.
Custom list markers
The original version of this post replaced list bullets by removing them with list-style: none and adding a character with ::before. Modern CSS has a simpler and better way: list-style-type accepts any string, and the ::marker pseudo-element lets you style the marker.
ul.ticks {
list-style-type: "\2713\00A0\00A0"; /* tick and two non-breaking spaces */
}
ul.ticks li::marker {
color: #15803d;
font-weight: 700;
}
- CSS properties
- HTML tags
- Colour generators
- CSS examples with longer text that wraps onto a second line, so you can see how it lines up
- Getting started
- Layout
- Typography
- Colour
The non-breaking spaces (\00A0) add a gap between the marker and the text, because ordinary spaces at the end of a marker string can be collapsed.
Why this is better: using list-style: none can stop some screen readers (software that reads pages aloud), such as Safari with VoiceOver, from announcing the element as a list. Keeping a real list marker avoids that problem, and the text also wraps neatly under itself rather than under the marker.
For numbered lists, or markers that change from item to item, take a look at the @counter-style rule. You can try different styles with our CSS Counter Style Preview.
Decorative separators
A Unicode ornament makes a lovely section divider. Rather than an empty <div>, use an <hr> element, which tells screen readers there's a change of topic, and add the ornament with ::after:
hr.fleuron {
height: 0;
margin: 32px 0 24px;
border: 0;
border-top: 1px solid #d1d5db;
overflow: visible; /* let the ornament show outside the hr */
text-align: center;
}
hr.fleuron::after {
content: "\2766" / ""; /* floral heart; empty alt text (see Accessibility) */
position: relative;
top: -0.75em; /* lift it onto the line */
padding: 0 12px;
background: #ffffff; /* match your page background to hide the line */
color: #6b7280;
font-size: 24px;
line-height: 1;
}
The end of one section of your article.
The start of the next section.
And another section after a starry divider.
The second divider uses the same technique with three four-pointed stars (\2726), separated by wide em spaces (\2003).
Tip: the ornament's background must match the page behind it to hide the line. On a page with a dark mode, set it to the same custom property you use for the page background. For more divider ideas, see our post on styling the <hr> tag.
Quotation marks
The original version of this post added curly quotation marks by typing them into content. CSS actually has a dedicated system for quotes: the quotes property sets which characters to use, and the open-quote and close-quote keywords insert them.
blockquote {
position: relative;
padding-left: 52px;
quotes: "\201C" "\201D" "\2018" "\2019"; /* β β then β β for quotes inside quotes */
}
blockquote::before {
content: open-quote;
position: absolute;
top: -12px;
left: 0;
color: #2563eb;
font-size: 72px;
line-height: 1;
}
blockquote::after {
content: no-close-quote; /* no visible mark, but keeps the quote count balanced */
}
Design is not just what it looks like and feels like. Design is how it works, and good CSS makes it workbeautifully.
The first pair of characters in quotes is used for the outer quotation, and the second pair for quotes nested inside it.
Quotes in other languages
Different languages use different quotation marks. If you use the HTML <q> element for short inline quotes, the browser adds the marks for you, and you can set the right marks for each language with the :lang() selector:
q:lang(fr) { quotes: "\00AB\202F" "\202F\00BB"; } /* Β« guillemets Β» with narrow spaces */
q:lang(de) { quotes: "\201E" "\201C"; } /* βGermanβ */
q:lang(ja) { quotes: "\300C" "\300D"; } /* γJapaneseγ */
English: Hello
French: Bonjour
German: Hallo
Japanese: γγγ«γ‘γ―
The HTML just sets the lang attribute, for example <q lang="fr">Bonjour</q>. Some browsers choose language-appropriate quotes automatically, but not all do, so setting them yourself gives consistent results. It's also one more reason to use <q> rather than typing quotation marks by hand.
Symbols and emoji
Some characters can display either as a plain text symbol, which takes on your text colour, or as a full-colour emoji, which looks different on every device and ignores your color setting. The original post used \2705 (β
), which always displays as an emoji.
For characters that can go either way, you can choose with an invisible variation selector placed straight after the character:
\FE0Easks for the text (symbol) style.\FE0Fasks for the emoji style.
\2714 (default)\2714\FE0E (symbol)\2714\FE0F (emoji)All three examples above have color: #be185d set. The symbol versions take the colour; the emoji version, where your device shows one, keeps its own colours.
Tip: not every font includes every character. If the font you're using doesn't have a character, the browser borrows it from another font on the device, so it may look slightly different from the surrounding text, or show as an empty box (often called "tofu") if no font has it. Stick to well-supported characters, and check them on a few devices.
Accessibility
Characters added with content aren't just decoration: screen readers usually read them aloud. A row of stars might be announced as "black star, black star, black starβ¦", and an arrow as "rightwards arrow", which is noisy and unhelpful.
Alternative text for generated content
The content property accepts alternative text after a slash, just like the alt attribute on an image:
/* Decorative: empty alt text, so screen readers skip it */
hr.fleuron::after {
content: "\2766" / "";
}
/* Meaningful: describe what the characters mean */
.rating::before {
content: "\2605\2605\2605\2605\2606"; /* fallback */
content: "\2605\2605\2605\2605\2606" / "Rated 4 out of 5";
}
Customer reviews
Alternative text in content works in Chrome and Edge, Firefox (128 onwards) and Safari (17.4 onwards).
Why the fallback line? A browser that doesn't understand the slash syntax ignores the whole declaration, so the character wouldn't appear at all. Putting a plain content line first means older browsers still show the character, and newer ones use the second line.
More accessibility tips
- Don't rely on a symbol alone to carry meaning. A β or β on its own may not be clear to everyone, so pair it with text, such as "Included" or "Not included".
- Hide decorative characters in HTML. If you type a decorative character straight into your HTML, wrap it in
<span aria-hidden="true">so screen readers skip it. - Keep important content in the HTML. Generated content can't be selected or copied in most browsers, so use CSS characters for decoration and labels, not for information people need.
Handy characters reference
Here are some characters that are especially useful in CSS:
| Character | Name | CSS | HTML |
|---|---|---|---|
| β’ | Bullet | \2022 | • |
| β | Tick (check mark) | \2713 | ✓ |
| β | Ballot X | \2717 | ✗ |
| β | Right arrow | \2192 | → |
| βΊ | Single right angle quote (handy for breadcrumbs) | \203A | › |
| β β | Curly double quotes | \201C \201D | “ ” |
| β¦ | Ellipsis | \2026 | … |
| β β | Black and white stars | \2605 \2606 | ★ ☆ |
| β¦ | Floral heart | \2766 | ❦ |
| Β© | Copyright sign | \00A9 | © |
| (invisible) | Non-breaking space | \00A0 |   |
| (new line) | Line feed: needs white-space: pre to show as a line break | \A | Use <br> |
Wrapping up
Unicode gives you thousands of ready-made symbols and ornaments that you can add with a single line of CSS, with no image files needed. Use ::marker and list-style-type for list bullets, the quotes property for quotation marks, and ::before or ::after for everything else. Watch out for the escape gotcha, choose between symbol and emoji styles deliberately, and give your characters alternative text so they help everyone rather than adding noise.