Encodes the specified string for use in cascading style sheets (CSS).
Assembly: System.Web (in System.Web.dll)
input contains a character that has an invalid Unicode value.
input contained a high surrogate code point that was not followed by a low surrogate code point.
input contained a low surrogate code point that was not preceded by a high surrogate code point.
This method encodes all characters except those that are in the safe list.
Put quotation marks (" ") around the resulting string before you add it to a cascading style sheet.
The following table lists the default safe characters.
Unicode code chart
Uppercase alphabetic characters
Lowercase alphabetic characters
The following table lists examples of inputs and the corresponding encoded outputs.
Anti-Cross Site Scripting Namespace
The CSS character escape sequence consists of a backslash character (\) followed by up to six hexadecimal digits that represent a character code from the ISO 10646 standard. (The ISO 10646 standard is effectively equivalent to Unicode.) Any character other than a hexadecimal digit terminates the escape sequence. If a character that follows the escape sequence is also a valid hexadecimal digit, it must either include six digits in the escape sequence or use a whitespace character to terminate the escape sequence. For example, \000020 denotes a space.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.