Entities in HTML

  • Some characters are reserved in HTML. For eg.
    • The less than symbol (<)
    • The greater than symbol (>)
  • If we use to try to output directly in HTML code, the browser will get confused.
  • For solving this we will use HTML entities.
  • HTML entities are used to display reserved characters in HTML.
  • The characters that are not on the keyboard can also replace with entities.
  • There are two ways to use entities.
    1. The entity name should start with '&'' and end with a semicolon ';'
          eg., &lt; (This is the entity for less than symbol). This will add '<' to the output.
    2. Preface the entity number with & and end with.
          eg., &#60;
  • The entity name is so easy to remember. But all the browsers will not support entity number. But for the support numbers are good.
  • Entity names are case sensitive.
  • All the symbols will not have the entity name. You must use an entity name to create them.
  • Some common entity names:
    1. &nbsp - Space
    2. &amp - @
    3. &lt - <
    4. &gt - >
    5. &copy; - c(rounded)


      <title>This is for testing</title>
      <p>The heading tag in html looks like &lt;h2&gt;</p>