Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk3 min

HTML Character References: How to Write Special Characters

HTML character references—often called entities—let you represent characters in markup. Learn the named and numeric forms, semicolon rules, and common ampersand pitfalls.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

HTML “entities” are more precisely called character references: ampersand-led sequences that represent characters in places where HTML permits them. Use a named reference such as ©, a decimal reference such as ©, or a hexadecimal reference such as ©. For reliable markup, match named-reference capitalization and include the terminating semicolon.

What are HTML character references?

“HTML entity” is the familiar informal term; the HTML Standard calls the syntax a character reference. It begins with an ampersand and stands for one or more Unicode code points in contexts where references are recognized. It is not a universal escape mechanism: whether a sequence is interpreted as a reference depends on where it appears in the HTML.

References are useful for writing characters that would otherwise be awkward or ambiguous in markup. For instance, a literal less-than sign can be written as <, and an ampersand that could begin a reference can be written as &.

Three forms of character reference

Form Syntax and example When it is useful Important detail
Named © represents © When a known name makes the markup easier to read Names are case-sensitive. Use the spelling and capitalization in the official named character references table.
Decimal numeric © represents code point 169 (U+00A9, ©) When you know the code point in decimal Numeric values have restrictions, and invalid values have defined parser recovery behavior.
Hexadecimal numeric © represents code point U+00A9 (©) When your Unicode reference gives the code point in hexadecimal Write x or X followed by hexadecimal digits. The same numeric restrictions apply.

The decimal form consists of &#, one or more decimal digits, and a semicolon. The hexadecimal form consists of &#x or &#X, one or more hexadecimal digits, and a semicolon. For authoring, numeric references must not denote a carriage return, a noncharacter, or a control character other than ASCII whitespace.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Named references are not always one name to one code point: some names map to two Unicode code points, and the table includes historical aliases. For an uncommon symbol, look up the exact name rather than relying on a short cheat sheet. Named and numeric forms are alternative spellings, not options with a documented rendering or performance advantage.

Use semicolons and exact spelling

Write the semicolon at the end of a character reference. Although HTML parsing recognizes certain historical spellings without one, that compatibility behavior is not the recommended authoring form. Named references are case-sensitive, so preserve the table’s capitalization; a different case may not be the same name.

The parser uses the longest matching named reference. In ordinary text, for example, &notit; is parsed as &not followed by it;, while ∉ is the complete reference for ∉. A semicolonless match in an attribute is subject to an additional rule, so the same-looking sequence can behave differently depending on context. These details are reasons to use complete, semicolon-terminated spellings rather than depending on parser recovery.

Escape a literal ampersand in attributes

If an ampersand in markup is followed by text that could be recognized as a reference, encode the literal ampersand as &amp;. This is especially important in attributes such as URLs. The Standard’s example <a href="?art&copy"> yields an attribute value containing ?art©, not the intended literal ?art&copy. Write <a href="?art&amp;copy"> to preserve the literal query text.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In attributes, a semicolonless named-reference match is not consumed when it is followed by an ASCII letter, digit, or equals sign. That exception does not make omitted semicolons dependable: use the semicolon after a reference, and encode a literal ampersand where ambiguity is possible. The Standard’s introduction to fragile syntax constructs explains this authoring concern.

What happens to invalid numeric references?

Numeric syntax does not guarantee that every number represents a valid, usable character. Under the HTML parsing rules, null, out-of-range, and surrogate values are parse errors that are resolved to U+FFFD, the replacement character. Some control values are remapped according to a table in the parser rules. Check that a numeric value is a valid code point before using it; do not assume the digits will produce the character you intended.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Quick reference for common characters

  • Less-than sign: &lt; or numeric &#60;.
  • Greater-than sign: &gt; or numeric &#62;.
  • Ampersand: &amp; or numeric &#38;.
  • Copyright sign: &copy;, &#169;, or &#xA9;.

The named spellings above are shown with their required semicolons. For additional names and their mapped code points, use the WHATWG reference table.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.