HTML Character Entities

HTML Character Entities
Nikhil
Published on 2021-07-02 08:22:46

Character Entities in HTML


Many symbols and special characters are required while developing a web page in HTML, but as we know that sometimes the use of characters directly may interfere with the actual HTML code which has certain characters reserved and also certain characters being not available on the keyboard. Thus, to avoid the conflict and at the same time to be able to use different symbols in our code w3 org provides us with 'Character Entities'. Character Entities are predefined with 'Entity Name'  &entity_name, and 'Entity Number' - &entity_number; so we need to use either of the two for the required symbol to be rendered on our page.

The list of few Character Entities can be found at https://dev.w3.org/html5/html-author/charref A simple example with the use of character entity for 'magnifying glass' :

<input type="text" placeholder=" &#128269; Search"/>

 

Common Special Characters


Some characters may be reserved for HTML and cannot be used directly as it may obstruct the actual HTML codes. For example, trying to display the left and right angle brackets (<>) in the source code may cause unexpected results in the output. Similarly, white spaces as written in the source code may not display as expected in the
output HTML. Some, like ☎, are not available in the ASCII character set.

For this purpose, character entities are created. These are of the form &entity_name; or &entity_number;. The following are some of the available HTML entities.

Character Description Entity Name Entity Number
“ ” non-breaking space &nbsp; &#160;
“<” less than &lt; &#60;
“>” greater than &gt; &#62;
“&” ampersand &amp; &#38;
“—” em dash &mdash; &#8212;
“–” en dash &ndash; &#8211;
“©” copyright &copy; &#169;
“®” registered trademark &reg; &#175;
“™” trademark &trade; &#8482;
“☎” phone &phone; &#9742;

Thus, to write
© 2021 Stack Exchange Inc.

the following HTML code is used:

<b>&copy; 2021 Stack Exchange Inc.</b>

ATutorialHub Related Guide

HTML Tutorials Comments (8)

Leave a Comment

Your email address will not be published. Required fields are marked*

User Comments

html tutorial comments

panduranga gupta

2021-07-05 07:03:13

good website for learning and help me a lot

html tutorial comments

raju

2021-09-25 14:58:47

The awsome website i am looking like for a long time, good work atutorialhub team keep doing

html tutorial comments

Shivani

2021-09-01 15:03:56

Learning a lot from the courses present on atutorialhub. The courses are very well explained. Great experience

html tutorial comments

Harshitha

2021-09-10 15:05:45

It is very helpful to students and easy to learn the concepts

html tutorial comments

Sowmya

2021-09-14 15:06:41

Great job Tutorials are easy to understand Please make use of it

html tutorial comments

Zain Khan

2021-09-18 15:07:23

Great content and customized courses.

html tutorial comments

Rudrakshi Bhatt

2021-09-09 15:08:10

Well structured coursed and explained really well!

html tutorial comments

Pavana Somashekar

2021-09-11 15:09:08

Good platform for beginners and learn a lot on this website