How to display Special Characters in HTML

preview_player
Показать описание
Follow this tutorial to learn how to display special characters through character entities in HTML

In this tutorial you will learn how to display special characters in HTML through HTML character entities.

There are several html special characters that are reserved for its own syntax or otherwise, for example the less-than sign cannot be directly used in your content or paragraphs. The less-than sign is mistaken as an opening of a tag by the browser. Similarly typing as many consecutive spaces between two words in HTML produces only 1 space on the browser. All of that is overcome by HTML character entities.

Step # 1 -- Character entity syntax
In order how to display html special characters, Each character entity follows one simple format as shown below.
&entityname

The ampersand sign tells the browser that the following is an entity name. This in turns guides the browser to display the appropriate character entity on the screen.

Step # 2 -- Using less-than character entity
Now that you know the pattern an entity is written in, we should move on to produce some results. Following is the code to show x is less than y by declaring the less-than character entity:
x < y

The browser interprets this character entity as a declaration for a less-than sign and doesn't count it as an opening of an HTML tag.

Step #3 -- Using non-breaking space character entity
The non-breaking space character entity is used where multiple consecutive spaces are needed to be placed. The number of spaces printed by the browser depends upon the number to consecutive non-breaking space character entity declarations. The code below declares two consecutive spaces in the text:
This is a     text

Step 4: List of characters in HTML
In the browser result, you should notice, that the normal space characters before, in between, and after the   entity are also considered as space. This is because these entity calls are individual items in HTML, and the browser allows one space character to be printed after and before every item. Thus the above code should produce 5 spaces; 1 normal space, then 1 for the character entity, and so on...

Below is a list of commonly used character entities in HTML.

Result Description Entity Name
non-breaking space  
less than <
greater than >
& ampersand &
¢ cent ¢
£ pound £
¥ yen ¥
€ euro &euro
§ section §
© copyright ©
® registered trademark ®
™ trademark &trade

And that's pretty much it for how to display special characters in HTML.
Рекомендации по теме
Комментарии
Автор

Thank you man, You're a life saver, I was kinda confused, but this video clarified everything ❤ writing in my native language is tough if you can't type special characters.😂😂

NoahM
Автор

How do I get my site to show the character code. As in I want to say for example "Copyright code = &copy;" . How do I get it to show the code not the character.

itsme
Автор

How do you do the x code? I mean i try doing <x></x> and it does nohing

ultradragon