Hi, friends!
Today, I’ll talk about special characters in HTML — an essential part of any web document. You’ll learn:
Ready? Let’s begin!
Special characters are unique symbols that either don’t exist on the keyboard or are misinterpreted by browsers when used directly. For example:
< and >, the browser will treat them as commands, not text.This is where special characters come to the rescue. Let’s look at some examples.
If you try to add the following code:
<html>
<head>
<title>Example</title>
</head>
<body>
</body>
</html>
the browser will treat it as part of the page, not plain text. To fix this, replace < and > with < and >. Here’s how it will look:
<html>
<head>
<title>Example</title>
</head>
<body>
</body>
</html>
Result:
<html>
<head>
<title>Example</title>
</head>
<body>
</body>
</html>
Convenient, isn’t it?
Regular spaces in HTML can be tricky. If you want multiple spaces, use . For example:
word1 word2
Result:
To insert a special character, use its code. For example, the copyright symbol (©):
All rights reserved © 2024.
Result:
All rights reserved © 2024.
| Character | Code | Description | Example |
|---|---|---|---|
| & | & | Ampersand | & |
| < | < | Less than | < |
| > | > | Greater than | > |
| “ | " | Double quotation marks | “ |
| ‘ | ' | Apostrophe | ‘ |
| © | © | Copyright sign | © |
| ® | ® | Registered trademark | ® |
| ™ | ™ | Trademark | ™ |
| € | € | Euro | € |
| £ | £ | Pound | £ |
| ¥ | ¥ | Yen | ¥ |
| ° | ° | Degree | ° |
| ± | ± | Plus-minus | ± |
| × | × | Multiplication | × |
| ÷ | ÷ | Division | ÷ |
| — | — | Em dash | — |
| – | – | En dash | – |
| | Non-breaking space | (no visual output) |
Try it yourself! Write a few lines of code using special characters and see how they work.
See you in the next lesson! 😊
Knowledge Check: HTML Basics Test
63
HTML from Scratch: Adding Audio and Video to Your Website — For Beginners. Lesson #26
82
HTML from Scratch: The download Attribute in HTML5 (for downloading files). Lesson #25
149
HTML from Scratch: Commenting in HTML. Lesson #24
506
HTML from Scratch: The DOCTYPE Tag. Lesson #23
124
Leave a Reply