CSS <string> Data Type

If this site has been useful, we’d love your support! Running this site takes time and resources, and every small contribution helps us keep creating valuable content. Consider buying us a coffee to keep things going strong!

Description

The <string> CSS data type represents character data surrounded with either single (') or double (") quote characters. Any Unicode characters can be included in the string, but many need to be expressed with escape sequences.

Unicode characters may also be entered directly, if the file is saved with the correct encoding and a @charset rule is declared at the top of the stylesheet file.

The CSS escape character is the backslash (). There are two ways to create an escape sequence:

  • as a backslash followed by the special character (e.g., " for a double quote or for a backslash);
  • as a backslash followed by a hexadecimal number representing the unicode value (e.g., 22 for a double quote, 263A for a smiley face or a for a line break); either lowercase or uppercase letters may be used for the hexadecimal digits.
For a complete list of Unicode characters, please visit Character Codes website.

Syntax

property: <string>;

Values

  • <string>Defines the characters used in the string.

Example

<div></div>
div::after {
   content: "We all ♥ CSSPortal.com";
}

Browser Support

The following table will show you the current browser support for the CSS string data type.

Desktop
Edge Chrome Firefox Opera Safari
12113.51
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
18410.11137

Last updated by CSSPortal on: 7th October 2023