HTML Entity Detail

HTML Entity - Ampersand

Ampersand is a reserved HTML characters and special typographic symbols. This HTML entity enables web developers to display this character reliably across all browsers without encoding issues.

Symbol preview
&
Unicode

U+00026

HTML entity

&

CSS code

\0026

Usage Examples

Always encode ampersands in HTML as & to avoid parsing errors. For example, use & in attribute values: href="page.php?id=1&name=test". In a sentence: use & instead of — like Johnson & Johnson.

About Ampersand

The ampersand (&) is one of the characters HTML treats as special. A raw ampersand can begin a character reference such as & or ©, so browsers may try to interpret it. In HTML text and inside attribute values, write & whenever you want a literal ampersand.

The symbol itself is a stylised ligature of the letters E and t, from the Latin word et, meaning "and". It was once recited as the 27th letter of the English alphabet, which is how the phrase "and per se and" eventually became the word ampersand.

Ampersands cause problems in several places at once: in HTML content, in attribute values such as links with more than one query parameter (?a=1&b=2), in XML and XHTML where a bare ampersand is a hard parse error, and in query strings where & is a parameter separator and must be percent-encoded as %26.

Encoding by context: in HTML content and attributes use &. In URL query strings and form data use %26. In JavaScript strings a literal & is fine, though some pipelines prefer the escape sequence. The numeric references & and & are equivalent to &.

Typical real-world cases are embedding a video or map URL that contains &, writing brand names such as "AT&T", and showing code samples on a page. Wrong encoding either silently drops query parameters (a broken link) or prints the wrong characters, for example a double-encoded & that renders as the text "&" instead of a single ampersand.

Because & is so common, escaping it correctly is one of the first habits of writing valid HTML and XML. It is also essential for safety: when user input is inserted into markup, correct escaping is part of what prevents injection attacks. If you are unsure which form to use, remember the rule of thumb: in markup use &, in URLs use %26, and everywhere else the raw & is usually correct.

Common Mistakes

⚠️

Mistake: Forgetting to encode & as & in HTML content or attributes

Fix: Always use & to display a literal ampersand in HTML. In URLs, use %26 instead.

⚠️

Mistake: Using & in query strings without URL encoding

Fix: In URLs, encode & as %26. The & character has special meaning as a query parameter separator.

Frequently Asked Questions

What is the HTML entity for an ampersand?

Use & for a literal ampersand in HTML. The numeric forms & and & produce exactly the same character.

Do I always have to escape & in HTML?

In text content and attribute values, yes. A bare & is invalid markup even though browsers often recover from it. In XML and XHTML it is a hard error.

Why do URLs use %26 instead of &?

In a URL, & separates query parameters. To pass a literal ampersand inside a value you percent-encode it as %26. & is an HTML-only notation and has no meaning in a raw URL.

What is the difference between & and &?

& renders a single ampersand. & is a double-encoded ampersand and renders the four characters "&" literally, which is a common bug in templating and CMS pipelines.

Can I use a bare & in XML or SVG?

No. Both XML and SVG follow XML rules, where a bare & is not allowed. Always write &, including inside SVG attribute values.

What keyboard shortcut types an ampersand?

Shift+7 on most US keyboards. The Windows Alt code is Alt 0038, and on macOS Shift+7 works on the standard layout.

Ampersand

Select any code to highlight it before copying.

Category: Special Chars & Html
Unicode U+00026
Hex Code &
HTML Code &
HTML Entity &
CSS Code \0026
Windows Shortcut Alt 0038
Mac Shortcut
HTML code example
CSS code example