HTML 인코딩(문자 집합)

为了正确显示 HTML 页面,Web 浏览器必须知道要使用哪个字符集。

从 ASCII 到 UTF-8

ASCII 是第一个字符编码标准。ASCII 定义了 128 种可以在互联网上使用的字符:数字(0-9)、英文字母(A-Z)和一些特殊字符,比如:! $ + - ( ) @ < >。

ISO-8859-1 是 HTML 4 的默认字符集。此字符集支持 256 个不同的字符代码。HTML 4 同时支持 UTF-8。

ANSI(Windows-1252)是原始的 Windows 字符集。 ANSI 与 ISO-8859-1 相同,不同之处在于 ANSI 具有 32 个额外的字符。

HTML5 规范鼓励 Web 开发人员使用 UTF-8 字符集,该字符集涵盖了世界上几乎所有的字符和符号!

HTML charset 属性

为了正确显示 HTML 页面,Web 浏览器必须了解页面中使用的字符集。

这在 <meta> 标签中指定:

<meta charset="UTF-8">

亲自试一试

字符集之间的差异

下表展示了上述字符集之间的区别:

Numb ASCII ANSI 8859 UTF-8 Description
32 space
33!!!!exclamation mark
34""""quotation mark
35####number sign
36$$$$dollar sign
37%%%%percent sign
38&&&&ampersand
39''''apostrophe
40((((left parenthesis
41))))right parenthesis
42****asterisk
4338383838&
엔드39393939'
알파벳40404040(
왼쪽 괄호41414141)
오른쪽 괄호****스타일
42++++플러스 기호
43,,,,콤마
45----하이픈
46....
47////밑줄
4800001
233334
53555554
6555555557
56888857
958585858:
콜론59595959;
좌표점60606060<
하이퍼스톤 기호61616161=
등호62626262>
가장자리 기호????의문표
64@@@@상업 @
65AAAA라틴 대문자 A
66BBBB라틴 대문자 B
67CCCC라틴 대문자 C
68DDDD라틴 대문자 D
69EEEE라틴 대문자 E
70FFFF라틴 대문자 F
71GGGG라틴 대문자 G
72HHHH라틴 대문자 H
73IIII라틴 대문자 I
74JJJJ라틴 대문자 J
75KKKK라틴 대문자 K
76LLLL라틴 대문자 L
77MMMM라틴 대문자 M
78NNNN라틴 대문자 N
79OOOO라틴 대문자 O
Latin capital letter MNNNNLatin capital letter N
OLatin capital letter OLatin capital letter OLatin capital letter OLatin capital letter O80
PLatin capital letter PLatin capital letter PLatin capital letter PLatin capital letter P81
QLatin capital letter QLatin capital letter QLatin capital letter QLatin capital letter Q82
RLatin capital letter RLatin capital letter RLatin capital letter RLatin capital letter R83
SLatin capital letter SLatin capital letter SLatin capital letter SLatin capital letter S84
TLatin capital letter TLatin capital letter TLatin capital letter TLatin capital letter T85
ULatin capital letter ULatin capital letter ULatin capital letter ULatin capital letter U86
VLatin capital letter VLatin capital letter VLatin capital letter VLatin capital letter V87
WLatin capital letter WLatin capital letter WLatin capital letter WLatin capital letter W88
XLatin capital letter XLatin capital letter XLatin capital letter XLatin capital letter X89
YLatin capital letter YLatin capital letter YLatin capital letter YLatin capital letter Y90
ZLatin capital letter ZLatin capital letter ZLatin capital letter ZLatin capital letter Z91
[left square bracketleft square bracketleft square bracketleft square bracket\
reverse solidus]]]]right square bracket
^circumflex accentcircumflex accentcircumflex accentcircumflex accent_
low line````grave accent
97aaaaLatin small letter a
98bbbbLatin small letter b
99ccccLatin small letter c
100ddddLatin small letter d
101eeeeLatin small letter e
102ffffLatin small letter f
103ggggLatin small letter g
104hhhhLatin small letter h
105iiiiLatin small letter i
106jjjjLatin small letter j
107kkkkLatin small letter k
108llllLatin small letter l
109mmmmLatin small letter m
110nnnnLatin small letter n
111ooooLatin small letter o
112ppppLatin small letter p
113qqqqLatin small letter q
114114114114114r
라틴 소문자 r115115115115s
라틴 소문자 s116116116116t
라틴 소문자 t117117117117u
라틴 소문자 u118118118118v
라틴 소문자 v119119119119w
라틴 소문자 w120120120120x
라틴 소문자 x121121121121y
라틴 소문자 y122122122122z
라틴 소문자 z123123123123{
왼쪽 꼴리는 괄호124124124124|
세로 줄125125125125}
오른쪽 꼴리는 괄호126126126126~
트림127    
DEL 128  
유로 기호 129129129single right-pointing angle quotation mark
 130  
단일로우 9 쿼테이션 마크 131  
호크를 가진 라틴 소문자 f 132  
듀얼로우 9 쿼테이션 마크   수평 세그마
134   호기
 다게  
듀얼 다게   커밍크림프 어시스턴트
137   백분율 기호
138   카론을 가진 라틴 대문자 S
139   단일 왼쪽 꼴리는 쿼테이션 마크
140   라틴 대문자 OE 라이그처
141 single right-pointing angle quotation mark
142   카론을 가진 라틴 대문자 Z
143 single right-pointing angle quotation mark
144    single right-pointing angle quotation mark
145 '  왼쪽 싱글 쿼테이션 마크
146 '  오른쪽 싱글 쿼테이션 마크
147 "  왼쪽 더블 쿼테이션 마크
148 "  오른쪽 더블 쿼테이션 마크
149 •  bullet
150 –  en dash
151 149  149
• bullet  –
en dash —  em dash
152 ˜  small tilde
153 ™  trade mark sign
154 š  Latin small letter s with caron
155 ›››single right-pointing angle quotation mark
156 œ  Latin small ligature oe
157   NOT USED
158    ž
Latin small letter z with caron 159159159Ÿ
Latin capital letter Y with diaeresis 160160160no-break space
¡ inverted exclamation markinverted exclamation markinverted exclamation mark¢
cent sign £££pound sign
¤ currency signcurrency signcurrency sign¥
yen sign 166166166¦
broken bar 167167167§
section sign 168168168¨
diaeresis 169169169©
copyright sign 170170170ª
feminine ordinal indicator 171171171«
left-pointing double angle quotation mark 172172172¬
not sign ­­­soft hyphen
174 ®®®registered sign
175 ¯¯¯macron
176 °°°degree sign
177 ±±±plus-minus sign
178 ²²²superscript two
179 ³³³superscript three
180 ´´´acute accent
181 µµµmicro sign
182 pilcrow sign
183 ···middle dot
184 ¸¸¸cedilla
185 ¹¹¹superscript one
186 ºººmasculine ordinal indicator
187 »»»right-pointing double angle quotation mark
188 ¼¼¼vulgar fraction one quarter
189 ½½½vulgar fraction one half
190 ¾¾¾vulgar fraction three quarters
191 ¿¿¿inverted question mark
192 ÀÀÀLatin capital letter A with grave
193 ÁÁÁLatin capital letter A with acute
194 ÂÂÂLatin capital letter A with circumflex
195 ÃÃÃLatin capital letter A with tilde
196 ÄÄÄLatin capital letter A with diaeresis
197 ÅÅÅLatin capital letter A with ring above
198 ÆÆÆLatin capital letter AE
199 ÇÇÇLatin capital letter C with cedilla
200 ÈÈÈLatin capital letter E with grave
201 ÉÉÉLatin capital letter E with acute
202 ÊÊÊLatin capital letter E with circumflex
203 ËËËLatin capital letter E with diaeresis
204 ÌÌÌLatin capital letter I with grave
205 ÍÍÍLatin capital letter I with acute
206 ÎÎÎLatin capital letter I with circumflex
207 ÏÏÏLatin capital letter I with diaeresis
208 ÐÐÐLatin capital letter Eth
209 ÑÑÑLatin capital letter N with tilde
210 ÒÒÒLatin capital letter O with grave
211 ÓÓÓLatin capital letter O with acute
212 ÔÔÔLatin capital letter O with circumflex
213 ÕÕÕLatin capital letter O with tilde
214 ÖÖÖLatin capital letter O with diaeresis
215 ×××multiplication sign
216 ØØØLatin capital letter O with stroke
217 ÙÙÙLatin capital letter U with grave
218 ÚÚÚLatin capital letter U with acute
219 ÛÛÛLatin capital letter U with circumflex
220 ÜÜÜLatin capital letter U with diaeresis
221 ÝÝÝLatin capital letter Y with acute
222 ÞÞÞLatin capital letter Thorn
223 ßßßLatin small letter sharp s
224 àààLatin small letter a with grave
225 áááLatin small letter a with acute
226 âââLatin small letter a with circumflex
227 ãããLatin small letter a with tilde
228 äääLatin small letter a with diaeresis
229 åååLatin small letter a with ring above
230 æææLatin small letter ae
231 çççLatin small letter c with cedilla
232 èèèLatin small letter e with grave
233 éééLatin 소문자 e with acute
234 êêêLatin 소문자 e with circumflex
235 ëëëLatin 소문자 e with diaeresis
236 ìììLatin 소문자 i with grave
237 íííLatin 소문자 i with acute
238 îîîLatin 소문자 i with circumflex
239 ïïïLatin 소문자 i with diaeresis
240 ðððLatin 소문자 eth
241 ñññLatin 소문자 n with tilde
242 òòòLatin 소문자 o with grave
243 óóóLatin 소문자 o with acute
244 ôôôLatin 소문자 o with circumflex
245 õõõLatin 소문자 o with tilde
246 öööLatin 소문자 o with diaeresis
247 ÷÷÷division sign
248 øøøLatin 소문자 o with stroke
249 ùùùLatin 소문자 u with grave
250 úúúLatin 소문자 u with acute
251 ûûûLatin 소문자 with circumflex
252 üüüLatin 소문자 u with diaeresis
253 ýýýLatin 소문자 y with acute
254 þþþLatin 소문자 thorn
255 ÿÿÿLatin 소문자 y with diaeresis

ASCII 문자 집합

ASCII는 0에서 31(또는 127) 사이의 값을 제어 문자로 사용합니다.

ASCII는 32에서 126의 값을 사용하여 문자, 숫자 및 기호를 표시합니다.

ASCII는 128에서 255 사이의 값을 사용하지 않습니다.

ANSI 문자집합 (Windows-1252)

0에서 127 사이의 값은 ANSI와 ASCII와 동일합니다.

ANSI는 128에서 159 사이의 값을 가진 독특한 문자 집합을 가집니다.

160에서 255 사이의 값은 ANSI와 UTF-8과 동일합니다.

ISO-8859-1 문자집합

0에서 127 사이의 값은 8859-1과 ASCII와 동일합니다.

8859-1은 128에서 159 사이의 값을 사용하지 않습니다.

160에서 255 사이의 값은 8859-1과 UTF-8과 동일합니다.

UTF-8 문자집합

0에서 127 사이의 값은 UTF-8과 ASCII와 동일합니다.

UTF-8은 12 8에서 159 사이의 값을 사용하지 않습니다.

160에서 255 사이의 값은 UTF-8과 ANSI 및 8859-1과 동일합니다.

UTF-8은 값 256에서 계속되며, 10,000개 이상의 다른 문자를 포함하고 있습니다.

심화된 연구를 위해, 우리의 완전한 HTML 문자집합 참조 가이드를 읽어 보세요.

@charset CSS 규칙

CSS @charset 규칙을 사용하여 스타일 시트에서 사용하는 문자 인코딩을 지정할 수 있습니다:

예제

스타일 시트의 인코딩을 Unicode UTF-8로 설정하십시오:

@charset "UTF-8";

자세한 내용은 우리의 CSS 참조 가이드에서 확인하세요 CSS @charset 규칙 의 내용.