Entities
HTML Entities
HTML entities are used to represent characters that may not be available on a standard keyboard. They are commonly utilized for:
- Copyright and trademark symbols
(©, ™)
- Special characters from different languages
(á, ñ, €)
- Mathematical notations
(∞, ≠)
- Symbols like bullets and section marks
(§, •)
Example
This text contains a copyright symbol © and a euro symbol €.
Ways to Represent Entities
- Character Entities
- Non-Breaking Space
Character Entities
Some characters are reserved in HTML
and need to be represented using entities to prevent conflicts with HTML tags.
- The entity format follows this pattern:
&entity_name;
- Numeric references use this format:
&#entity_number;
For instance, to display <
, you can use <
or <
.
Character entities start with &#
and can either be:
- A decimal reference number representing the Unicode decimal code (e.g.,
©
for ©). - A named entity for widely used symbols (e.g.,
©
for ©).
Non-Breaking Space
One of the most frequently used entities is the non-breaking space.
This entity prevents automatic line breaks, ensuring words remain together in a sentence.
‑
) ensures hyphenated words stay on the same line.Common HTML Entities
Symbol | Description | Entity Name | Entity Number |
---|---|---|---|
Non-breaking space | |   | |
< | Less than | < | < |
> | Greater than | > | > |
& | Ampersand | & | & |
" | Double quotation mark | " | " |
' | Single quotation mark | ' | ' |
¢ | Cent | ¢ | ¢ |
£ | Pound | £ | £ |
¥ | Yen | ¥ | ¥ |
€ | Euro | € | € |
© | Copyright | © | © |
® | Registered trademark | ® | ® |
Combining Diacritical Marks
A diacritical mark is a small symbol added to a letter.
Accents such as grave ( ̀ )
and acute ( ́ )
modify letters, forming characters that may not exist in certain character sets.
Mark | Character | Construct | Result |
---|---|---|---|
``` | a | à | à |
' | a | á | á |
^ | a | â | â |
~ | a | ã | ã |
``` | O | Ò | Ò |
' | O | Ó | Ó |
^ | O | Ô | Ô |
~ | O | Õ | Õ |
Using Character Entities in HTML
Character entities can be included directly in HTML like this:
This text contains a copyright symbol © and a euro symbol €.
Conclusion
HTML entities are essential for representing characters that aren't directly available on a keyboard or could cause conflicts with HTML tags. They can represent special symbols like copyright (©), trademark (™), currency symbols (€, £), and even mathematical notations.
Symbols
HTML symbols, also known as character entities, such as < for <, represent reserved characters. They begin with & and end with ;, preventing confusion in the browser.
Events
HTML events are actions that trigger JavaScript code, such as clicks, key presses, or page loads, allowing for dynamic behavior and interactivity on web pages.