Strings

A string value must be enclosed in double or single quotes. So, to include a quote inside a string, you’ll need to escape it with a backslash character, like so:

ol#breadcrumbs:before {
  content: "You are \"here\": ";
}
html {
  font-family: 'Grey\'s Bold',serif;
}

Of course, it’s often easier to use the opposite quotation character around the string—if you need a double quote inside the string, surround the whole string with single quotes, and vice versa:

ol#breadcrumbs:before {
  content: 'You are "here": ';
}
html {
  font-family: "Grey's Bold",serif;
}

If you want a string to contain characters that can’t easily be typed from the keyboard, characters that can’t be expressed in the style sheet’s character encoding, or non-printable characters, you can represent those characters using CSS escape notation.

Note also that a string value in CSS can’t contain a literal new line. If you need to include a new-line character inside a string value, use a character escape (\a ).

User-contributed notes

There are no comments yet.

Related Products