HTML Entity for Exclamation Mark (!)

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 1 Code Example
Unicode U+0021

What You'll Learn

How to display the Exclamation Mark (!) in HTML using hexadecimal, decimal, named entity, and CSS escape methods. This character is U+0021 (EXCLAMATION MARK) in the Basic Latin block (ASCII)—fundamental punctuation for emphasis, alerts, and strong statements on the web.

Render it with !, !, the named entity !, or CSS escape \21. You can usually type ! directly in UTF-8 content; entities help when encoding explicitly in attributes or sensitive markup.

⚡ Quick Reference — Exclamation Mark

Unicode U+0021

Basic Latin (ASCII)

Hex Code !

Hexadecimal reference

HTML Code !

Decimal reference

Named Entity !

Explicit encoding

Reference Table
Name           Value
────────────   ──────────
Unicode        U+0021
Hex code       !
HTML code      !
Named entity   !
CSS code       \21
Meaning        Exclamation mark (punctuation)
Related        U+2049 = Exclamation question mark (⁉)
1

Complete HTML Example

This example demonstrates the Exclamation Mark (!) using hexadecimal code, decimal HTML code, the named entity, and a CSS content escape:

html
<!DOCTYPE html>
<html>
<head>
 <style>
  #point:after{
   content: "\21";
  }
 </style>
</head>
<body>
<p>Exclamation Mark using Hexadecimal: &#x21;</p>
<p>Exclamation Mark using HTML Code: &#33;</p>
<p>Exclamation Mark using HTML Entity: &excl;</p>
<p id="point">Exclamation Mark using CSS Entity: </p>
</body>
</html>
Try it Yourself

🌐 Browser Support

The Exclamation Mark entity is universally supported in modern browsers:

Chrome 1+
Firefox 1+
Safari 1+
Edge 12+
Opera 4+
Android 4.4+
iOS Safari 1+

👀 Live Preview

See the exclamation mark (!) in alert and emphasis context:

Alert Warning!
Large glyph !
Entities &excl; !
Numeric refs &#x21; &#33; &excl;
vs interrobang !   vs   ⁉

🧠 How It Works

1

Hexadecimal Code

&#x21; uses the Unicode hexadecimal value 21 to display the Exclamation Mark. The x prefix indicates hexadecimal format.

HTML markup
2

Decimal HTML Code

&#33; uses the decimal Unicode value 33 to display the same character.

HTML markup
3

Named Entity

&excl; is the semantic named entity for the exclamation mark—useful when encoding explicitly in markup or attributes.

HTML markup
4

CSS Entity

\21 is used in CSS stylesheets, particularly in the content property of pseudo-elements like ::before and ::after.

CSS stylesheet
=

Same visual result

All four methods produce the glyph: !. Unicode U+0021 in the Basic Latin block. Serve HTML as UTF-8.

Use Cases

The Exclamation Mark (!) commonly appears in:

📝 Punctuation

Exclamatory sentences, headings, titles, and emphatic body text.

⚠️ Alerts

Warning messages, error labels, and notification copy.

🔘 UI

Call-to-action buttons and labels (e.g. Submit&excl;).

📢 Marketing

Slogans, banners, and promotional headlines.

💬 Dialogue

Chat interfaces and quotes expressing strong emotion.

📄 Forms

Required-field indicators and validation messages.

💡 Best Practices

Do

  • Use &excl; when explicit encoding is needed in attributes
  • Type ! directly in UTF-8 body text when safe
  • Serve pages with UTF-8 (<meta charset="utf-8">)
  • Use sparingly for real emphasis or alerts
  • Use CSS content for reusable alert icons

Don’t

  • Overuse exclamation marks—they lose impact quickly
  • Confuse ! with ⁉ (exclamation question mark / interrobang)
  • Put CSS escape \21 in HTML text nodes
  • Rely on entities when a plain ! in UTF-8 suffices
  • Mix entity styles randomly in one file

Key Takeaways

1

Three HTML references plus CSS all render !

&#x21; &#33; &excl;
2

For CSS stylesheets, use the escape in the content property

\21
3

Unicode U+0021 — EXCLAMATION MARK

4

&excl; is the standard named entity

5

Basic Latin (ASCII) punctuation

❓ Frequently Asked Questions

Use &#x21; (hex), &#33; (decimal), &excl; (named), or \21 in CSS content. You can also type ! directly in UTF-8 text.
U+0021 (EXCLAMATION MARK). Basic Latin block (ASCII). Hex 21, decimal 33. Punctuation, emphasis, and alerts.
For exclamatory punctuation, alerts, UI emphasis, marketing copy, form validation messages, and any content that needs a clear exclamation mark.
Use &excl; when you need explicit encoding in HTML attributes, generated markup, or contexts where the raw character could be misinterpreted. In normal UTF-8 body text, ! is fine.
HTML entities (&#33;, &#x21;, or &excl;) go directly in markup. The CSS escape \21 is used in stylesheets, typically in the content property of pseudo-elements. Same visual result, different layers of the stack.

Explore More HTML Entities!

Discover 1500+ HTML character references — punctuation, symbols, and more.

All HTML Entities →

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