HTML for Web Development

0% completed

Previous
Next
HTML Special Characters

HTML special characters are symbols and reserved characters that cannot be directly written in HTML because they have specific meanings (e.g., < is used to define tags). To display these characters on a webpage, you need to use their HTML entities. HTML entities start with an ampersand (&) and end with a semicolon (;).

Common HTML Special Characters

Below is a table of commonly used HTML special characters, their meanings, and examples.

CharacterDescriptionEntity CodeExample
<Less than sign&lt;2 &lt; 5 → 2 < 5
>Greater than sign&gt;5 &gt; 2 → 5 > 2
&Ampersand&amp;Tom &amp; Jerry → Tom & Jerry
"Double quotation mark&quot;"Hello" → "Hello"
'Single quotation mark&apos;'Hello' → 'Hello'
©Copyright symbol&copy;&copy; 2025 → © 2025
®Registered trademark symbol&reg;&reg; → ®
£Pound currency symbol&pound;&pound;100 → £100
¥Yen currency symbol&yen;&yen;500 → ¥500
Euro currency symbol&euro;&euro;50 → €50
¢Cent symbol&cent;50&cent; → 50¢
§Section symbol&sect;&sect; 3 → § 3
±Plus-minus sign&plusmn;&plusmn;5 → ±5
×Multiplication sign&times;5 &times; 5 → 5 × 5
÷Division sign&divide;10 &divide; 2 → 10 ÷ 2
  (Space)Non-breaking space&nbsp;Hello&nbsp;World → Hello World

Examples of HTML Special Characters

Example 1: Displaying Reserved Characters

Reserved characters like < and > cannot be used directly in HTML because they are interpreted as tags. Use their HTML entities instead.

HTML

. . . .

Explanation:

  • < is replaced with &lt; to display it as a less-than symbol on the webpage.

Example 2: Using the Ampersand (&)

The ampersand (&) is a reserved character and must be represented using &amp;.

HTML

. . . .

Explanation:

  • & is represented as &amp; to prevent it from being misinterpreted as the start of another HTML entity.

Example 3: Currency Symbols

HTML entities can be used to display currency symbols like Pound, Euro, and Yen characters seamlessly.

HTML

. . . .

Explanation:

  • &pound;, &euro;, and &yen; are used to represent £, €, and ¥ respectively.

Example 4: Copyright and Trademark Symbols

Special characters like © and ® are commonly used for branding and legal text.

HTML

. . . .

Explanation:

  • &copy; displays the copyright symbol, and &reg; displays the registered trademark symbol.

Example 5: Using Non-Breaking Space

The &nbsp; entity is used to create extra spaces between words or to prevent line breaks.

HTML

. . . .

Explanation:

  • &nbsp; adds non-breaking spaces between "Hello" and "World".

Best Practices for Using Special Characters

  1. Use Entities for Reserved Characters:

    • Always use entities like &lt; for < and &gt; for > to avoid conflicts with HTML tags.
  2. Use Descriptive Entities:

    • Prefer descriptive entities (e.g., &copy; for ©) to improve code readability.
  3. Check Compatibility:

    • Ensure that the special characters are supported by all major browsers.

Mastering HTML special characters allows you to display complex symbols and reserved

.....

.....

.....

Like the course? Get enrolled and start learning!
Previous
Next