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 © 2023</p>
Entity Syntax
Example: Entities start with &
and end with ;
, e.g., <
for <.
<p>Use <p> 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 < 10 means "5 is less than 10" © 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: < > & © .
- Entities ensure correct display of reserved characters.
- Check entity references if unsure of the correct code.