The <string>
CSS data type represents a string. It is formed by a Unicode characters delimited by either double (") or single (') quotes. A double quoted string cannot contain double quotes unless escaped using a backslash (\). The same practice applies for single quoted strings, they cannot contain single quotes unless escaped using a backslash (\). The backslash character must be escaped to be part of the string.
New lines are not accepted unless escaped by using a line feed character such as \A or \00000a. However, strings can span over several lines. In that case, the new line must be escaped using a \ as the last character of the line.
Characters can be described using their Unicode code point in hexadecimal, when escaped using \. \27 represents the single quote (').
ExamplesEdit
/* Simple quote escaping */
"Awesome string with double quotes"
"Awesome string with \" escaped double quotes"
'Awesome string with single quotes'
"Awesome string with \' escaped single quotes"
/* New line in a string */
"Awesome string with \Aline break"
/* String spanning over two lines (these two strings are exactly the same) */
"A really long \
awesome string"
"A really long awesome string"
SpecificationsEdit
Specification | Status | Comment |
---|---|---|
CSS Values and Units Module Level 3 The definition of '<string>' in that specification. |
Candidate Recommendation | No significant change from CSS Level 2 (Revision 1) |
CSS Level 2 (Revision 1) The definition of '<string>' in that specification. |
Recommendation | Explicitly defined; allows 6-digit Unicode escaped characters |
CSS Level 1 The definition of '<string>' in that specification. |
Recommendation | Implicitly defined; allows 4-digit Unicode escaped characters |