Special Characters
Exercise
- In the "index.html" file, write the following code:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My First Web Page</title> </head> <body> </body> </html>
- Save.
- If "Live Server" is not already running, right-click anywhere in the editor and select "Open with Live Server" from the context menu.
- Add the following between the opening and closing tags of the body:
<!-- Special Characters --> <!-- Trademark Symbol --> <p>Trademark ™</p> <!-- Copyright Symbol --> <p>Copyright ©</p>
- Save.
- In the browser, you should see the following:
Code Walkthrough and Explanation
™
Special character codes in HTML are used to display characters that are not included on a standard keyboard or
are
difficult to type. They are often used to display characters such as reserved HTML characters (e.g.,
<
and >
), special characters (e.g., copyright symbol), or foreign characters.
Each special character code in HTML is represented by a unique code, known as an entity code or entity
reference that
starts with an &
symbol and ends with a ;
symbol.
There are several lists of special character codes available online, such as the HTML Character Entity References on the W3Schools website - https://www.w3schools.com/html/html_symbols.asp
These lists provide a comprehensive reference of all the special character codes that can be used in HTML. It's important to note that some special characters can also be entered directly into HTML using Unicode but the entity code is the preferred method since it is more widely supported across different browsers and platforms.
Experiment with the Code
- Try adding other special characters.
Video and Code References
Questions? Subscribe and ask in the video comments: