HTML Entities

HTML entities are used to display characters that have special meaning in HTML or are not easily typed from a keyboard. By using entities, you ensure that special characters (like © or ≤) display correctly and do not break your markup.

Key Topics

Special Characters

Example: Displaying © symbol as ©.

<p>All rights reserved &copy; 2023</p>

Entity Syntax

Example: Entities start with & and end with ;, e.g., &lt; for <.

<p>Use &lt;p&gt; for paragraphs.</p>

Entities Example

This example shows a paragraph using multiple entities. A full code sample is provided below.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Entities Example</title>
</head>
<body>
    <p>5 &lt; 10 means &quot;5 is less than 10&quot; &copy; 2023</p>
</body>
</html>

Explanation: Using entities ensures that characters like < and " display as intended, rather than being interpreted as HTML markup.

Key Takeaways

  • Use HTML entities to display special characters safely.
  • Entities start with & and end with ;.
  • Common entities: &lt; &gt; &amp; &copy; &nbsp;.
  • Entities ensure correct display of reserved characters.
  • Check entity references if unsure of the correct code.