HTML Entities

HTML Entities are special codes that represent characters in HTML that would otherwise be interpreted as part of the code, like < and >. Entities ensure that these characters are displyed correcctly on the webpage.

HTML Entities Syntax

Explanation of Syntax:

  • Each entity begins with an ampersand (&) and ends with a semicolon (;).
  • Between & and ;, the entity name or number represents a specific character.
&amp;   <!-- & character -->
&lt;    <!-- < character -->
&gt;    <!-- > character -->
&quot;  <!-- " character -->
&apos; <!-- ' character -->




HTML Entities Example Code

Explanation of Code:

  • The <!DOCTYPE html> declaration and <html>, <head>, and <body> tags set up the page structure.
  • The <p> tags in the <body> section contain sentences demonstrating HTML entities:
    • &amp; represents the ampersand (&) character.
    • &lt; and &gt; represent the less-than (<) and greater-than (>) characters.
    • &quot; represents the quotation mark (") character.
    • &apos; represents the apostrophe (') character.
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML Entities Example</title>
</head>
<body>
    <h1>Displaying Special Characters with HTML Entities</h1>
    <p>Use &amp; to display &amp; and &lt; to display &lt;.</p>
    <p>Quotes are represented as &quot; and apostrophes as &apos;.</p>
</body>
</html>




HTML Labs

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top