HTML: Learn to Code Character Entities

HTML: Learn to Code Character Entities

  • HTML
  • 2 mins read

In HTML, many of the web pages you create will require special characters such as a copyright symbol, trademark symbol, and registered symbol, etc. To display these special characters; you use character entities. In this HTML tutorial, you'll learn how to code character entities.

Common HTML Character Entities

EntityCharacter
&&
&lt;<
&gt;>
&copy;©
&reg;®
&trade;
&cent;¢
&deg;°
&plusmn;±
&lsquo;' (opening single quote)
&rsquo;' (closing single quote)
&ldquo;“ (opening double quote)
&rdquo;” (closing double quote)
&nbsp;A non-breaking space.

Notes on HTML Character Entities

  • All character entities start with an ampersand (&) and end with a semicolon (;). Then the rest of the entity identifies the character it represents.
  • Character entities can be used to display special characters in an HTML document.
  • HTML provides a variety of character entities in addition to the ones above.

Example

<html lang="en">

<head>
    <style>
        body {
            background-color: #ffaec8;
        }
    </style>
</head>

<body>
    <h1>HTML Character Entities</h1>
    <h3>Closing Single Quote</h3>
    <p>It&rsquo;s time to start your Christmas shopping.</p>
    <h3>Opening and Closing Double Quotes</h3>
    <p>President John F. Kennedy said, &ldquo; And so, my fellow Americans,
        <br> ask not what your country can do for you; ask what you can do for your
        <br> country.&rdquo;
    </p>
    <h3>Non-Breaking Space</h3>
    <p>&nbsp;&nbsp;&nbsp;&nbsp;Turning fear into hope, medical futurist Dr. Alan J. Russell will
        <br> discuss the science of regenerating damaged or diseased human body parts, while offering real
        <br> hope for the future
        <br> of human health.</p>
    <h3>Copyright and Ampersand</h3>
    <p>&copy; 2019 John Loney &amp; Associates, Inc.</p>
</body>

</html>

Output

The output would be as shown in the featured image of this article.

See also: