October 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 PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

How to Display the Literal Text `&` in HTML

To show the literal text & in an HTML page, write & in the source. The browser parses the first character reference and displays the entity spelling.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To display the literal text & in an HTML page, write & in the HTML source. The browser interprets the first ampersand as the start of a character reference and renders the visible text &.

What to write in the HTML source

HTML source and rendered text are different: the browser parses character references in the source before displaying the result.

As an Amazon Associate I earn from qualifying purchases.

HTML source Rendered text
& &
& &

For example, this paragraph source:

<p>Write &amp;amp; to show the text &amp;amp;.</p>

renders as:

Write &amp; to show the text &amp;.

In an HTML page, the source needs the additional escaping even inside <code> or <pre>. Those elements affect presentation; they do not stop the browser from parsing character references.

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

Why the extra escaping works

An ampersand begins an HTML character reference. The named reference &amp; represents the ampersand character, U+00026. So when the browser encounters &amp;amp; in the source, it interprets the first &amp; as one ampersand and displays the remaining letters amp; as ordinary text.

The same result can be produced with a numeric character reference for the initial ampersand: &#38;amp; uses decimal 38, while &#x26;amp; uses hexadecimal 26. Both render as &amp;. For this example, &amp;amp; is usually easiest to recognize.

Do not confuse HTML page output with forum code display

Suggestions such as splitting the text with an empty tag may depend on a particular forum’s post renderer. They are not the general solution for outputting the literal spelling in an HTML page. In page markup, escape the ampersand as shown above.

Rank #2
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
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What about XHTML or XML?

This explanation is for HTML syntax. XHTML served as XML follows XML parsing rules, so do not assume that every HTML parsing detail applies unchanged. If the document is XML, follow the rules for that serialization.

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

The HTML Standard describes character references as beginning with a U+0026 ampersand: HTML syntax: character references. MDN lists the named ampersand reference and its code point: Character references.

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.