An HTML entity is a string that is used to display reserved and invisible characters, which would otherwise be treated as HTML code. HTML entities begin with an ampersand(&) and end with a semicolon(;). They are written as-

&entityName; or &#entityNumber;

HTML reserves some characters, and it is possible that the browser may misinterpret them as mark-up elements. There are also some characters that are not present on a standard keyboard but are desired on a web-page. For such situations, HTML entities prove to be highly beneficial. It is easier to remember an entity name than type from a standard keyboard.

For example, The less than sign,<, is written as &lt or &#60.

When to use HTML Entities?

  • When the editor does not support unicode, HTML entities are useful.
  • We can use the HTML entities for displaying characters such as ‘<’ or ‘>’ which may otherwise be interpreted as code while displaying.
  • For displaying specific characters such as ‘<’ or ‘>’, we use HTML entities. These characters may otherwise be interpreted as code while displaying on the browser.

Let us suppose we want to write and display

on our webpage. We can write the characters ‘<’ and ‘>’ using the entity name or the numerical character reference.

#html tutorials #html entities #html

HTML Entities - Character Entities and Diacritical Marks
2.75 GEEK