HTML Entity for Ampersand (&)

Beginner
6 min read
Updated: Sep 2026
1 example
Unicode U+0026

What Is the Ampersand Entity?

Ampersand (&) is Unicode U+0026 — the familiar “and” sign. In HTML it is reserved: a bare & starts a character reference, so you almost always write it as an entity when you want a literal ampersand on the page.

Remember
Character     &
Unicode       U+0026
Hex entity    &
Decimal       &
Named entity  &
CSS escape    \0026
Rule          Escape & in text and attributes

Prefer the named form & in hand-written HTML — it is short, standard, and required for valid XML/XHTML as well. Use numeric forms or CSS escapes when generating markup or stylesheet content.

Quick Reference

One table for every form you will actually use.

FormCodeWhere it goes
Named entity&HTML text & attributes (preferred)
Hex entity&HTML markup
Decimal entity&HTML markup
CSS escape\0026Stylesheet content
Bare &—Avoid in markup — escape instead

When to Use Which

SituationUse
Normal text (“Ben & Jerry”)&
Query strings in href / src?a=1&b=2
Generated / ASCII-only markup& or &
CSS ::before / ::aftercontent: "\0026"
Starting another entity (é)Leave that & as part of the entity name

Live Preview

Ampersand rendered safely from character references.

Inline text Salt & pepper
Large glyph &
Brand-style AT&T · R&D
Monospace a=1&b=2
All forms Named: & | Hex: & | Decimal: &

Complete HTML Example

One page that shows ampersand with hex, decimal, named entity, CSS escape, and a real-world phrase. Use View Output or open the live editor.

Hex + Decimal + Named + CSS + Phrase

Five safe ways to produce & without a bare ampersand in markup.

html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Ampersand (&amp;) in HTML</title>
  <style>
    #point::after {
      content: "\0026";
    }
  </style>
</head>
<body>
  <p>Ampersand using Hex Code: &#x26;</p>
  <p>Ampersand using HTML Code: &#38;</p>
  <p>Ampersand using Named Entity: &amp;</p>
  <p id="point">Ampersand using CSS Entity: </p>
  <p>In a phrase: Rock &amp; Roll</p>
</body>
</html>
Try It Yourself

How It Works

1. Hex: U+0026 → &#x26; in HTML. The browser turns it into &.

2. Decimal: same code point as 38 → &#38;. Same result as hex.

3. Named: &amp; is the standard HTML name — clearest choice for everyday markup.

4. CSS: use \0026 in content (not an HTML entity). #point::after appends that & after the paragraph text.

5. Phrase: Rock &amp; Roll shows a literal ampersand between words — never write bare & there.

Pitfalls & Tips

Common mistakes when working with the ampersand entity.

Escape

Always escape literals

Write &amp; for a visible &. A bare & can start an unintended entity.

Double

Do not double-encode

&amp;amp; displays as &amp; text. Encode once unless you truly want that string.

URLs

Escape & in attributes

In href, write ?q=a&amp;page=2 — not a bare & between parameters.

CSS vs HTML

Do not mix escapes

\0026 belongs in CSS. &amp; / &#38; belong in HTML.

Other

Also escape < and "

Reserved siblings: <, >, ".

Semicolon

End references

Always finish with ; — write &amp;, not &amp.

Browser Support

Ampersand (U+0026) and its entity forms (&amp;, &#38;, &#x26;, CSS \\0026) are supported in all mainstream browsers.

✓ Universal support

Ampersand (&)

Encode with named, hex, decimal, or CSS escape — same glyph everywhere. Prefer &amp; in markup.

100% Browser coverage
Google Chrome Supported
Yes
Microsoft Edge Supported
Yes
Mozilla Firefox Supported
Yes
Apple Safari Supported
Yes
Opera Supported
Yes
Internet Explorer All versions
Yes
U+0026 / entities Full support

Bottom line: Prefer &amp; in HTML text and attributes. Use &#38; / &#x26; when generating markup, and \\0026 only inside CSS content.

Key Takeaways

  • Unicode: ampersand is U+0026 (decimal 38).
  • HTML: prefer &amp; (or &#38; / &#x26;).
  • CSS: use \0026 inside content for generated text.
  • Rule: escape every literal & in text and attributes.

One line: U+0026 → &amp; / &#38; / &#x26; / CSS \0026.

Frequently Asked Questions

Use &amp; (named), &#38; (decimal), &#x26; (hex), or the CSS escape \0026 in content. Prefer &amp; in everyday HTML text and attributes.
U+0026 (hex 0026, decimal 38). It belongs to the Basic Latin (ASCII) block.
In HTML, & starts a character reference. An unescaped & can confuse parsers or break attributes. Escaping with &amp; always shows a literal ampersand safely.
In HTML attributes, query-string separators should be written as &amp; — for example href="/search?q=a&amp;page=2". Browsers still resolve the correct URL.
HTML entities (&amp;, &#38;, or &#x26;) go in markup. The CSS escape \0026 is used in stylesheets (usually in content on ::before/::after). Both render &.
HTML5 is forgiving in some cases, but bare & is still a common source of bugs. Always use &amp; (or a numeric form) for a literal ampersand in text and attributes.

Did you know?

Ampersand is Unicode U+0026 (decimal 38). It is a reserved HTML character — always prefer &amp; (or &#38; / &#x26;) in text and attributes so the browser does not treat & as the start of another entity.

Next: Angle

Learn the HTML entity for the angle symbol (∠) used in geometry and math text.

Angle tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful