CSS <string> Data Type

The CSS <string> data type represents a string. A string is character data surrounded with either single (') or double (") quote characters.

When you see <string> (including the < and >) anywhere in the CSS specifications, this refers to the fact that the value can be any valid string.

For example, the content property accepts the following values:

Which means that you can provide a string as one of the possible values.

Here's an example of a string value:

So this could be used within a property such as the content property, like this:

Here's a working example:

Escaping Characters

Some characters need to be escaped before they will render properly. For example, if you use double quotes to indicate the string, and the string itself contains a double quote character, you'll need to escape it. Otherwise it will interfere with the double quotes that indicate the string. The same applies to the single quote character.

Double quotes can be escaped as "\"" or as "\22".

Single quotes can be escaped as '\'' or as '\27'.

However, if the string is enclosed in double quotes, you can use single quotes within the string without escaping them (and vice-versa).

So any of the following are fine:

CSS Specifications