HTML Entities


HTML entities are special codes that allow you to display characters in your web pages that would otherwise be interpreted as HTML code. In this tutorial, we’ll cover the basics of HTML entities and how to use them in your web pages.

What is an HTML entity?

An HTML entity is a code that represents a special character or symbol. For example, the less than sign (<) can be represented by the HTML entity code &lt;. HTML entitity are used to display characters that are reserved for HTML, such as the less than and greater than signs, or that are not part of the standard ASCII character set.


Common HTML entities

Here are some common HTML entitity and their corresponding codes:

  • &lt; – less than sign (<)
  • &gt; – greater than sign (>)
  • &amp; – ampersand (&)
  • &quot; – double quotation mark (“)
  • &apos; – single quotation mark or apostrophe (‘)
  • &cent; – cent sign (¢)
  • &pound; – pound sign (£)
  • &yen; – yen sign (¥)
  • &euro; – euro sign (€)
  • &copy; – copyright symbol (©)
  • &reg; – registered trademark symbol (®)
  • &trade; – trademark symbol (™)
  • &ndash; – en dash (–)
  • &mdash; – em dash (—)
  • &nbsp; – non-breaking space

How to use HTML entities

To use an HTML entity in your web page, simply replace the special character with its corresponding HTML entity code. For example, to display the copyright symbol, you would use the HTML entity code &copy;. Here’s an example:

<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
</head>
<body>
<h1>My Page</h1>
<p>&copy; 2023 My Company, Inc.</p>
</body>
</html>

In the above example, we have used the HTML entity code &copy; to display the copyright symbol in the paragraph element.

So that, HTML entities are a useful tool for displaying special characters and symbols in your web pages. By using HTML entitity, you can ensure that your content is displayed correctly across all devices and browsers. Remember to always use the correct HTML entity code for the character or symbol you want to display.