DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk2 min

How to Write an Ampersand in HTML

Write & in HTML source to display a literal ampersand. Learn how named and numeric character references work and when other symbols need escaping.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To display a literal ampersand (&) in HTML, write & in the source. The browser parses that character reference and renders &.

What are HTML ampersand codes?

They are character references: sequences in HTML source that begin with an ampersand and represent a character. “HTML entity” is a familiar synonym, although entity is older terminology. The WHATWG HTML Standard defines the syntax; MDN’s character-reference glossary gives a concise overview.

As an Amazon Associate I earn from qualifying purchases.

For example, a browser reads & as the ampersand character, Unicode U+0026. The source spelling and the character displayed on the page are different: the code contains the reference, while the rendered page shows the character it represents.

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

Which ampersand spelling should you use?

Use & for the readable, conventional spelling. These three forms all represent the same character:

#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
Form HTML source Represents
Named & &
Decimal numeric & & (U+0026; decimal 38)
Hexadecimal numeric & & (U+0026; hexadecimal 26)

The named spelling is easiest to recognize. Numeric references can be useful when you know the character’s code point or need to represent a character without a familiar named form. For ordinary ampersands, there is little reason to prefer them over &.

Why does HTML use character references?

Some characters also have a role in HTML syntax. An unescaped less-than sign can begin a tag, for example, so a reference lets you show markup-like text without having the browser interpret it as markup. Common named references include:

  • &lt; displays <.
  • &gt; displays >.
  • &quot; displays a double quotation mark.
  • &apos; displays an apostrophe.
  • &amp; displays an ampersand.

To show the text <p> rather than create a paragraph element, write &lt;p&gt; in the HTML source. The browser displays the angle brackets and letter p as text.

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

Do you need a semicolon, and does capitalization matter?

For new HTML, use the semicolon-terminated spellings shown above: &amp;, &#38;, and &#x26;. Named references are case-sensitive, and the standard’s reference list includes some historical variants without semicolons. Those exceptions are not a good pattern to rely on in new code; consistent semicolon use is clearer.

HTML also defines an “ambiguous ampersand”: an ampersand followed by one or more ASCII letters or digits and a semicolon when the sequence does not match a named reference. In attribute values, such text must not be left as an ambiguous ampersand. Encoding a literal ampersand as &amp; avoids confusion when it precedes text that could be read as a reference.

What if the page visibly shows “&amp;”?

If the page displays the letters &amp; instead of a single ampersand, the visible text may have been escaped more than once, or the page may be presenting the source spelling as text. Check the HTML source and the way the content is inserted: one character reference should be parsed to produce one ampersand.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Do all symbols need HTML codes?

No. In a document served and interpreted as UTF-8, modern browsers can handle many non-ASCII characters directly; you do not need to replace every symbol with a character reference. References remain useful when a character overlaps with HTML syntax, when you want a named spelling for readability, or when you need to express a particular code point. See MDN’s guide to basic HTML syntax for further examples.

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

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.

Leave a Reply

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

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

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.