In HTML some characters are reserved like less than (<) and greater than (>), SO whenever your text content these characters, Browser will mix them with tags, Reserved characters in HTML must be replaced considering quality entities.
So in this case we use character entities to display reserved characters correctly.
&entity_name; or &entity_number;
so display the above example we use : (<) and (<) for less than
Second Definition: 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.
A simple example with the use of character entity for 'magnifying glass :
<input type="text" placeholder=" 🔍 Search"/>
Non-breaking Space is one the most usable Entity to adding space
In HTML if you write 5 spaces in your text, the browser will remove all extra space, and only one space is left in this case browser only display 1 space and remove 4, that's why we use (Non-breaking Space) character entity
Example: without entity and with
NUMBER | ASCII ANSI ISO-8859-1 UTF-8 | DESCRIPTION |
---|---|---|
32 | space | |
32 | Space | |
33 | ! | Exclamation Mark |
34 | " | Quotation Mark |
35 | # | Hash Sign |