HTML Reference ยท Characters and Codes
ASCII Table
The complete ASCII table: all 128 codes with decimal and hex values, characters, control-code abbreviations and descriptions, plus notes on using them in HTML.
ASCII (American Standard Code for Information Interchange) is a 7-bit character code from the 1960s with exactly 128 codes, numbered 0 to 127. It covers the English letters, the digits, common punctuation and 33 non-printing control codes.
ASCII still matters because it is the foundation of everything that came after. The first 128 Unicode code points are the ASCII characters, in the same order, and UTF-8 stores each of them as the very same single byte. A file that contains only ASCII is therefore also valid UTF-8, ISO-8859-1 and Windows-1252. In HTML you can write any of them as a numeric reference, such as A for A.
The layout has some useful patterns:
- Digits
0โ9are codes 48โ57, so a digit's value is its code minus 48. - Uppercase
AโZ(65โ90) and lowercaseaโz(97โ122) are exactly 32 apart: one bit (0x20) switches the case. - Every printable character sits between 32 (space) and 126 (
~).
Try it
The 128 codes
Control characters (0โ31)
| Dec | Hex | Char | Description |
|---|---|---|---|
| 0 | 00 | NUL | Null; marks the end of a string in C |
| 1 | 01 | SOH | Start of heading |
| 2 | 02 | STX | Start of text |
| 3 | 03 | ETX | End of text; Ctrl+C |
| 4 | 04 | EOT | End of transmission; Ctrl+D (end of input in Unix terminals) |
| 5 | 05 | ENQ | Enquiry |
| 6 | 06 | ACK | Acknowledge |
| 7 | 07 | BEL | Bell; makes a terminal beep (\a) |
| 8 | 08 | BS | Backspace (\b) |
| 9 | 09 | HT | Horizontal tab (\t) |
| 10 | 0A | LF | Line feed, the Unix and web new line (\n) |
| 11 | 0B | VT | Vertical tab (\v) |
| 12 | 0C | FF | Form feed; page break (\f) |
| 13 | 0D | CR | Carriage return (\r); Windows ends lines with CR LF |
| 14 | 0E | SO | Shift out |
| 15 | 0F | SI | Shift in |
| 16 | 10 | DLE | Data link escape |
| 17 | 11 | DC1 | Device control 1 (XON); resumes output |
| 18 | 12 | DC2 | Device control 2 |
| 19 | 13 | DC3 | Device control 3 (XOFF); pauses output |
| 20 | 14 | DC4 | Device control 4 |
| 21 | 15 | NAK | Negative acknowledge |
| 22 | 16 | SYN | Synchronous idle |
| 23 | 17 | ETB | End of transmission block |
| 24 | 18 | CAN | Cancel |
| 25 | 19 | EM | End of medium |
| 26 | 1A | SUB | Substitute; Ctrl+Z (end of file on Windows consoles) |
| 27 | 1B | ESC | Escape; starts terminal escape sequences such as colors |
| 28 | 1C | FS | File separator |
| 29 | 1D | GS | Group separator |
| 30 | 1E | RS | Record separator |
| 31 | 1F | US | Unit separator |
Space, punctuation and digits (32โ64)
| Dec | Hex | Char | Description |
|---|---|---|---|
| 32 | 20 | (space) | Space |
| 33 | 21 | ! | Exclamation mark |
| 34 | 22 | " | Quotation mark (straight double quote) |
| 35 | 23 | # | Number sign (hash) |
| 36 | 24 | $ | Dollar sign |
| 37 | 25 | % | Percent sign |
| 38 | 26 | & | Ampersand |
| 39 | 27 | ' | Apostrophe (straight single quote) |
| 40 | 28 | ( | Left parenthesis |
| 41 | 29 | ) | Right parenthesis |
| 42 | 2A | * | Asterisk |
| 43 | 2B | + | Plus sign |
| 44 | 2C | , | Comma |
| 45 | 2D | - | Hyphen-minus |
| 46 | 2E | . | Full stop (period) |
| 47 | 2F | / | Solidus (slash) |
| 48 | 30 | 0 | Digit zero |
| 49 | 31 | 1 | Digit one |
| 50 | 32 | 2 | Digit two |
| 51 | 33 | 3 | Digit three |
| 52 | 34 | 4 | Digit four |
| 53 | 35 | 5 | Digit five |
| 54 | 36 | 6 | Digit six |
| 55 | 37 | 7 | Digit seven |
| 56 | 38 | 8 | Digit eight |
| 57 | 39 | 9 | Digit nine |
| 58 | 3A | : | Colon |
| 59 | 3B | ; | Semicolon |
| 60 | 3C | < | Less-than sign |
| 61 | 3D | = | Equals sign |
| 62 | 3E | > | Greater-than sign |
| 63 | 3F | ? | Question mark |
| 64 | 40 | @ | Commercial at |
Uppercase letters and symbols (65โ96)
| Dec | Hex | Char | Description |
|---|---|---|---|
| 65 | 41 | A | Latin capital letter A |
| 66 | 42 | B | Latin capital letter B |
| 67 | 43 | C | Latin capital letter C |
| 68 | 44 | D | Latin capital letter D |
| 69 | 45 | E | Latin capital letter E |
| 70 | 46 | F | Latin capital letter F |
| 71 | 47 | G | Latin capital letter G |
| 72 | 48 | H | Latin capital letter H |
| 73 | 49 | I | Latin capital letter I |
| 74 | 4A | J | Latin capital letter J |
| 75 | 4B | K | Latin capital letter K |
| 76 | 4C | L | Latin capital letter L |
| 77 | 4D | M | Latin capital letter M |
| 78 | 4E | N | Latin capital letter N |
| 79 | 4F | O | Latin capital letter O |
| 80 | 50 | P | Latin capital letter P |
| 81 | 51 | Q | Latin capital letter Q |
| 82 | 52 | R | Latin capital letter R |
| 83 | 53 | S | Latin capital letter S |
| 84 | 54 | T | Latin capital letter T |
| 85 | 55 | U | Latin capital letter U |
| 86 | 56 | V | Latin capital letter V |
| 87 | 57 | W | Latin capital letter W |
| 88 | 58 | X | Latin capital letter X |
| 89 | 59 | Y | Latin capital letter Y |
| 90 | 5A | Z | Latin capital letter Z |
| 91 | 5B | [ | Left square bracket |
| 92 | 5C | \ | Reverse solidus (backslash) |
| 93 | 5D | ] | Right square bracket |
| 94 | 5E | ^ | Circumflex accent (caret) |
| 95 | 5F | _ | Low line (underscore) |
| 96 | 60 | ` | Grave accent (backtick) |
Lowercase letters, symbols and DEL (97โ127)
| Dec | Hex | Char | Description |
|---|---|---|---|
| 97 | 61 | a | Latin small letter a |
| 98 | 62 | b | Latin small letter b |
| 99 | 63 | c | Latin small letter c |
| 100 | 64 | d | Latin small letter d |
| 101 | 65 | e | Latin small letter e |
| 102 | 66 | f | Latin small letter f |
| 103 | 67 | g | Latin small letter g |
| 104 | 68 | h | Latin small letter h |
| 105 | 69 | i | Latin small letter i |
| 106 | 6A | j | Latin small letter j |
| 107 | 6B | k | Latin small letter k |
| 108 | 6C | l | Latin small letter l |
| 109 | 6D | m | Latin small letter m |
| 110 | 6E | n | Latin small letter n |
| 111 | 6F | o | Latin small letter o |
| 112 | 70 | p | Latin small letter p |
| 113 | 71 | q | Latin small letter q |
| 114 | 72 | r | Latin small letter r |
| 115 | 73 | s | Latin small letter s |
| 116 | 74 | t | Latin small letter t |
| 117 | 75 | u | Latin small letter u |
| 118 | 76 | v | Latin small letter v |
| 119 | 77 | w | Latin small letter w |
| 120 | 78 | x | Latin small letter x |
| 121 | 79 | y | Latin small letter y |
| 122 | 7A | z | Latin small letter z |
| 123 | 7B | { | Left curly bracket (brace) |
| 124 | 7C | | | Vertical line (pipe) |
| 125 | 7D | } | Right curly bracket (brace) |
| 126 | 7E | ~ | Tilde |
| 127 | 7F | DEL | Delete; originally punched out every hole on paper tape to erase a character |
About the control characters
Codes 0โ31 and 127 were designed to drive teleprinters and terminals, not to be displayed. Only a few still matter on the web:
| Code | Name | Where you meet it today |
|---|---|---|
| 9 | Tab (HT) | Indentation in source code; inside <pre> and <textarea> it is preserved. |
| 10 | Line feed (LF) | The standard line ending in HTML, CSS, JavaScript and on Linux and macOS. |
| 13 | Carriage return (CR) | Windows line endings are CR LF; HTML parsers turn CR LF and lone CR into LF. |
| 12 | Form feed (FF) | Counted as whitespace by HTML and CSS, but rarely used. |
| 27 | Escape (ESC) | Starts ANSI escape sequences that color terminal output. |
| 0 | Null (NUL) | Never valid in HTML text: the parser reports an error and drops it or swaps in U+FFFD, the replacement character. |
- HTML whitespace is exactly five characters: space (32), tab (9), line feed (10), form feed (12) and carriage return (13). In normal text, runs of them collapse to a single space.
- Don't use control-character references.
to(other than tab, line feed and form feed) andare parse errors in HTML, and most of them are forbidden in XML 1.0. - Extended ASCII is not one thing. Codes 128โ255 were never part of ASCII. Different "code pages" used them for different characters, which is why the web standardized on UTF-8. See Character sets.
Related
- Character entities โ named references for characters beyond ASCII
- URL encoding โ which ASCII characters must be escaped in URLs
- Character sets โ UTF-8, Windows-1252 and others
- Lesson: Character Encoding and UTF-8
- Lesson: HTML Entities