W3docs

ASCII

ASCII is the first character-encoding scheme used between computers on the Internet. See the full table of characters and HTML entity codes.

ASCII, the acronym for the "American Standard Code for Information Interchange," is the first character-encoding scheme used between computers on the Internet. This page is a reference: it lists every ASCII character together with the HTML numeric character reference (for example A for A) you can use to insert it.

Modern character encoding schemes like UTF-8 and ISO-8859 are backward-compatible with ASCII.

When Do You Actually Need ASCII Codes?

In modern HTML you declare the encoding once with <meta charset="UTF-8"> in the <head>. Once UTF-8 is in effect, you can type letters, digits, punctuation, and even accented or non-Latin characters directly in your source file — there is no need to replace A with &#65;. Numeric ASCII references are mostly useful in three situations:

  • Reserved markup characters. <, >, &, and " have special meaning in HTML. To show them as literal text you must escape them, e.g. &#60; (or the named entity &lt;) for <.
  • Invisible or ambiguous characters. A non-breaking space (&#160; / &nbsp;) or other whitespace you can't tell apart by looking at the source.
  • Tooling that can't emit UTF-8. Older systems or generators that only output 7-bit ASCII.

There are two equivalent ways to write any code point as an entity:

  • Decimal: &#38; (the number is the character's ASCII/Unicode value).
  • Hexadecimal: &#x26; (same character, value written in base 16, with an x prefix).

For the handful of reserved characters, named entities such as &lt;, &gt;, &amp;, and &quot; are usually preferred because they read more clearly. See HTML Entities for the full named-entity reference, and UTF-8 Encoding for characters beyond the 128-character ASCII range.

The ASCII Character Set

The ASCII character set was designed in the 1960s as a standard for computers and hardware devices, such as printers and tape drives.

Originally, ASCII was based on the English alphabet. It is a 7-bit character set containing 128 characters: the numbers 0–9, uppercase and lowercase English letters A–Z, basic punctuation symbols, and special characters.

Most character sets used in modern computers, HTML, and the Internet are backward-compatible with ASCII.

Below is a table listing the 128 ASCII characters and their equivalent HTML entity codes.

ASCII Printable Characters

ASCII CharacterHTML Entity CodeDescription
space
!!exclamation mark
""quotation mark
##number sign
$$dollar sign
%%percent sign
&&ampersand
''apostrophe
((left parenthesis
))right parenthesis
**asterisk
++plus sign
,,comma
--hyphen
..period
//slash
00digit 0
11digit 1
22digit 2
33digit 3
44digit 4
55digit 5
66digit 6
77digit 7
88digit 8
99digit 9
::colon
;;semicolon
<<less-than
==equals-to
>>greater-than
??question mark
@@at sign
AAuppercase A
BBuppercase B
CCuppercase C
DDuppercase D
EEuppercase E
FFuppercase F
GGuppercase G
HHuppercase H
IIuppercase I
JJuppercase J
KKuppercase K
LLuppercase L
MMuppercase M
NNuppercase N
OOuppercase O
PPuppercase P
QQuppercase Q
RRuppercase R
SSuppercase S
TTuppercase T
UUuppercase U
VVuppercase V
WWuppercase W
XXuppercase X
YYuppercase Y
ZZuppercase Z
[[left square bracket
\\backslash
]]right square bracket
^^caret
__underscore
``grave accent
aalowercase a
bblowercase b
cclowercase c
ddlowercase d
eelowercase e
fflowercase f
gglowercase g
hhlowercase h
iilowercase i
jjlowercase j
kklowercase k
lllowercase l
mmlowercase m
nnlowercase n
oolowercase o
pplowercase p
qqlowercase q
rrlowercase r
sslowercase s
ttlowercase t
uulowercase u
vvlowercase v
wwlowercase w
xxlowercase x
yylowercase y
zzlowercase z
{{left curly brace
||vertical bar
}}right curly brace
~~tilde

ASCII Device Control Characters

The ASCII device control characters (except horizontal tab, line feed, and carriage return) are rarely used in HTML documents. Originally, ASCII control characters (range 0–31, plus 127) were designed to control hardware devices.

Note: Write these codes without leading zeros — the decimal references are &#0; through &#9;, not &#00;/&#09;. The equivalent hexadecimal form (e.g. &#x09; for a tab) may pad with a zero, but the decimal form should not. These control characters are non-printing: most of them produce no visible output in a browser, so they are listed here for completeness rather than for everyday use.

ASCII CharacterHTML Entity CodeDescription
NULnull character
SOHstart of header
STXstart of text
ETXend of text
EOTend of transmission
ENQenquiry
ACKacknowledge
BELbell (ring)
BSbackspace
HT horizontal tab
LF line feed
VTvertical tab
FF form feed
CR carriage return
SOshift out
SIshift in
DLEdata link escape
DC1device control 1
DC2device control 2
DC3device control 3
DC4device control 4
NAKnegative acknowledge
SYNsynchronize
ETBend transmission block
CANcancel
EMend of medium
SUBsubstitute
ESCescape
FSfile separator
GSgroup separator
RSrecord separator
USunit separator
DELdelete (rubout)

DEL (code 127) is also a non-printing control character — it was historically used to erase a character on punched tape, not to display anything.

Practical Usage Example

The cases where references really earn their keep are the reserved markup characters. Below, &#34; lets you put a literal quotation mark inside a double-quoted attribute value, and &#60;/&#62; show literal angle brackets in content without the browser treating them as a tag:

<!-- &#34; (a quote) inside a double-quoted attribute -->
<a href="#" title="The &#34;best&#34; link">Hover me</a>

<!-- &#60; and &#62; render as < and > instead of starting a tag -->
<p>Use the &#60;p&#62; element for paragraphs.</p>

<!-- &#38; (an ampersand) shown as literal text -->
<p>Fish &#38; Chips</p>

The same three characters have named equivalents — &quot;, &lt;, &gt;, and &amp; — which most authors prefer for readability:

<a href="#" title="The &quot;best&quot; link">Hover me</a>
<p>Use the &lt;p&gt; element for paragraphs.</p>
<p>Fish &amp; Chips</p>

Practice

Practice
In a UTF-8 HTML document, which character most often still needs an entity reference like < or <?
In a UTF-8 HTML document, which character most often still needs an entity reference like < or <?
Was this page helpful?