Entities, Symbols, Charset & XHTML
Some characters break HTML if typed raw — like < and &. Use entities: < for <, > for >, & for &.
HTML Entities
Some characters break HTML if typed raw — like < and &. Use entities: < for <, > for >, & for &.
Entities start with & and end with ;. They display as normal characters in the browser.
Real-life example: Entities are like escape codes — you write a secret symbol so the system knows you mean a literal < not a new tag.
<p>5 < 10 and Tom & Jerry</p>
<p>Copyright © 2026 Rishtaara</p>HTML Symbols
Many math and currency symbols have entities or Unicode: & euro;, & pound;, & times;, & divide;, & plusmn;.
You can also paste Unicode characters directly if your file is UTF-8.
Real-life example: Symbols are like special keys on a Hindi-English keyboard — one code gives ₹, ©, or °.
<p>Temperature: 25°C</p>
<p>Price: €10 or ₹999</p>HTML Emojis
Emojis are Unicode characters. With UTF-8 charset you can type them directly: 😀 🎉 📚.
Decimal or hex codes also work: 😀 for 😀.
Real-life example: Emojis in HTML are like stickers on your notebook — same stickers work if your notebook supports Unicode (UTF-8).
<p>Welcome to the course! 🎉</p>
<p>Code emoji: 📚</p>HTML Charset
<meta charset="UTF-8" /> in head tells the browser to read all languages, symbols, and emoji correctly.
Save your .html files as UTF-8 in your editor. Without this, Hindi or emoji may show as boxes.
Real-life example: Charset is like choosing Hindi+English keyboard layout — wrong layout and typing looks broken.
<head>
<meta charset="UTF-8" />
<title>नमस्ते — Hello</title>
</head>URL Encode
URLs cannot have spaces or special characters raw. Browsers encode them: space becomes %20, & becomes %26.
When you build links in JavaScript, use encodeURIComponent() for query values.
Real-life example: URL encode is like writing PIN code in an address — spaces and symbols get a safe coded form for the post office.
<a href="https://example.com/search?q=html%20tutorial">Search HTML tutorial</a>HTML vs XHTML
XHTML was a stricter version — all tags closed, lowercase, quoted attributes. HTML5 is the standard today and is more forgiving.
Write clean HTML5 anyway: close tags, quote attributes, one root <html>. That habit works everywhere.
Real-life example: XHTML was like strict exam handwriting rules. HTML5 is the friendly teacher — but neat writing still gets better marks.
- Use <!DOCTYPE html> for HTML5
- Close tags and quote attributes for quality
- XHTML is legacy — learn HTML5