HTML Entities

HTML entities are special characters or symbols that can be inserted into HTML documents using a code or string of characters that represent that specific entity. For example, the entity for the copyright symbol is ©. When the browser reads this code it will display the copyright symbol rather than the string of characters.

Examples: ©, >, <, &, (non-breaking space), etc.

How to use HTML entities

HTML entities can be used in HTML documents by including the entity code within the HTML code.

For example, to insert a copyright symbol in an HTML document, you would include the following code:

<p>Copyright &copy; 2022 My Website</p>

This would display the text "Copyright © 2022 My Website" in the browser.

You can also use HTML entities in HTML attributes such as the alt attribute of an image.

For example:

<img src="example.jpg" alt="Example &copy;">

It's important to note that some HTML entities have a corresponding Unicode character that can be used instead.

For example, instead of using the entity code &copy;, you can use the Unicode character ©. However, using the entity code is more reliable as it will work with older browsers that do not support Unicode characters.

Some commonly used HTML entities

Here is a list of some commonly used HTML entities, their entity name, entity number, and a brief description:

  • &nbsp; (non-breaking space) - This entity is used to create a non-breaking space in HTML, which will prevent text from wrapping to the next line. It can be used to add extra spacing between words or characters.
  • &lt; (less than) - This entity is used to insert the less than symbol < in HTML.
  • &gt; (greater than) - This entity is used to insert the greater than symbol > in HTML.
  • &amp; (ampersand) - This entity is used to insert the ampersand symbol & in HTML. It is often used in URLs and query strings.
  • &copy; (copyright) - This entity is used to insert the copyright symbol © in HTML.
  • &reg; (registered trademark) - This entity is used to insert the registered trademark symbol ® in HTML.
  • &euro; (euro) - This entity is used to insert the euro symbol in HTML.
  • &yen; (yen) - This entity is used to insert the yen symbol ¥ in HTML.
  • &pound; (pound) - This entity is used to insert the pound symbol £ in HTML.
  • &mdash; (em dash) - This entity is used to insert an em dash in HTML.
  • &ldquo; (left double quote) - This entity is used to insert a left double quotation mark in HTML.
  • &rdquo; (right double quote) - This entity is used to insert a right double quotation mark in HTML.

This is just a small sample of the many different HTML entities available. It's worth noting that there are many other entities available for different languages, mathematical symbols, and special characters.

HTML Basics