<string>

<string> CSS 자료형은 연속한 문자 집합을 나타냅니다. content, font-family, quotes 등 많은 CSS 속성에서 사용합니다.

구문

<string> 자료형은 큰따옴표(")나 작은따옴표(')로 둘러싼 임의 개수의 유니코드 문자로 구성됩니다.

대부분의 문자는 문자 그대로 표현할 수 있습니다. 또, 모든 문자는 역슬래시(\)로 시작하는 16진수 유니코드 코드 포인트로 작성할 수 있습니다. 예를 들어 \22는 큰따옴표, \27은 작은따옴표, \A9는 저작권 기호(©)를 나타냅니다.

Importantly, certain characters which would otherwise be invalid can be escaped with a backslash. These include double quotes when used inside a double-quoted string, single quotes when used inside a single-quoted string, and the backslash itself. For example, \\ will create a single backslash.

To output new lines, you must escape them with a line feed character such as \A or \00000A. In your code, however, strings can span multiple lines, in which case each new line must be escaped with a \ as the last character of the line.

참고: &nbsp;&#8212; 등 HTML 엔티티는 CSS <string>에서 사용할 수 없습니다.

예제

/* 간단한 문자열 */
"This string is demarkated by double quotes."
'This string is demarkated by single quotes.'

/* 문자 이스케이프 */
"This is a string with \" an escaped double quote."
"This string also has \22 an escaped double quote."
'This is a string with \' an escaped single quote.'
'This string also has \27 an escaped single quote.'
"This is a string with \\ an escaped backslash."

/* 문자열 내 줄바꿈 */
"This string has a \Aline break in it."

/* 여러 줄을 차지하는 문자열 (둘의 결과는 같음) */
"A really long \
awesome string"
"A really long awesome string"

명세

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 Explicit definition; allows 6-digit Unicode escaped characters.
CSS Level 1
The definition of '<string>' in that specification.
Recommendation Implicit definition; allows 4-digit Unicode escaped characters.

브라우저 호환성

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
<string>Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support YesSafari Full support 1WebView Android Full support ≤37Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support YesSafari iOS Full support 1Samsung Internet Android Full support Yes
Unicode escaped characters (\xx)Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 6Opera Full support YesSafari Full support 1WebView Android Full support ≤37Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support YesSafari iOS Full support 1Samsung Internet Android Full support Yes

Legend

Full support  
Full support