CSS Reference ยท Units and Values
String and identifier values
Reference for the CSS string and identifier value types: quoting rules, escape sequences, unquoted keywords and where each type is used.
CSS has two ways to write text-like values. A string (<string>) is quoted text such as "Hello". An identifier (<ident>) is an unquoted name such as serif, flex or bold. Strings carry arbitrary characters. Identifiers are keywords or names, and they follow stricter spelling rules.
Strings appear in content, quotes, font-family names with spaces, attribute selectors and @import. Identifiers make up nearly every keyword value in CSS.
a::after { content: " (link)"; } q { quotes: "ยซ" "ยป"; } body { font-family: "Segoe UI", system-ui, sans-serif; }
Try it
Syntax
<string> = "..." | '...' <ident> = [ letter | _ | non-ASCII | escape ] followed by letters, digits, - and _
Escapes inside a string:
| Escape | Meaning |
|---|---|
\" or \' |
The quote character itself. |
\\ |
A backslash. |
\2192 |
The Unicode character with that hex code (1 to 6 hex digits). A space after it ends the escape. |
\A |
A line feed (newline). Shows as a break only with white-space: pre or pre-line. |
| backslash + newline | Continues the string on the next source line, adding nothing. |
Values
| Type | Description |
|---|---|
<string> |
Text in single or double quotes. A raw, unescaped newline inside makes it invalid. |
<ident> |
A name without quotes. Case-insensitive for built-in keywords, case-sensitive for author-chosen names. |
<custom-ident> |
An author-chosen identifier that is not a reserved keyword; see custom identifiers. |
Usage notes
- Quote style is free. Choose
"or'to avoid escaping the other one. - Font names. Quote family names that contain spaces or digits at the start (
"Times New Roman"). Generic families such asserifmust stay unquoted, or they become a font named serif. - Identifiers cannot start with a digit.
1colis not a valid class selector without escaping (.\31 col). - Hyphen starts. Identifiers may start with a single
-followed by a letter or_, which is how custom properties and vendor prefixes work. contenttakes strings, not HTML.content: "<b>"shows those characters literally.- Accessibility. Text added through
contentis exposed to many screen readers, so do not put essential information there.
Browser support
Strings and identifiers have been supported by every browser for decades.
Related
contentโ generates text from stringsquotesโ quotation marks for<q>font-familyโ names and generic families- Lesson: Syntax