Science Knowings: HTML Course For Social Media

HTML Entities

Catch-Up: HTML Structure

Previously, we learned about HTML structure and the different elements used to create web pages. Now, let's dive into the world of HTML entities!

What are HTML Entities?

HTML Entities

HTML entities are special characters or symbols that can't be directly represented using standard keyboard characters. They are used to display special characters or symbols that are not available on a standard keyboard as well as to prevent ambiguity or conflicts.

For example, to display the copyright symbol (©), you can use the entity ©.

Why Use Entities?

  • To display special characters or symbols not available on a standard keyboard.
  • To prevent ambiguity or conflicts. For instance, using & instead of & ensures the ampersand character (&) is interpreted correctly.
  • To improve code readability and maintainability.

Types of Entities

There are three main types of HTML entities:
  1. Character Entities: Use predefined names to represent characters.
  2. Special Characters and Predefined Entities: Represent special characters or symbols, such as the copyright symbol (©).
  3. Numeric Entities: Use numeric codes to represent characters.

Character Entities

Character Entities

Character entities use predefined names to represent characters. Here's an example:

&lt; represents the < character. &gt; represents the > character.

Special Characters and Predefined Entities

Special Characters and Predefined Entities

These entities represent special characters or symbols, such as:

  • &copy; -> ©: copyright symbol
  • &trade; -> ™: trademark symbol
  • &reg; -> ®: registered trademark symbol

Numeric Entities

Numeric Entities

Numeric entities use numeric codes to represent characters. Here's the format: &# followed by the character's Unicode code point; &#38; represents the & character.

Numeric entities are useful when the character's name is unknown or when working with legacy systems.

Entity Conversion Tools

Entity Conversion Tools

There are various online tools available to convert characters to their corresponding HTML entities and vice versa.

For example, you can use the HTML Entity Encoder/Decoder tool at: https://www.w3schools.com/tags/ref_entities.asp

When to Use Entities

When to Use Entities

You should use HTML entities when:

  • The desired character is not available on your keyboard.
  • You want to avoid ambiguity or conflicts.
  • You want to improve the readability and maintainability of your code.

Entities for Special Characters

Entities for Special Characters

Here are some common entities for special characters:

  • &quot;: double quotation mark (")
  • &apos;: single quotation mark (')
  • &amp;: ampersand (&)

Entities for Mathematical Symbols

Entities for Mathematical Symbols

Here are some entities for mathematical symbols:

  • &plus;: plus sign +
  • &minus;: minus sign −
  • &times;: multiplication sign ×

Entities for Currency Symbols

Entities for Currency Symbols

Here are some entities for currency symbols:

  • &dollar;: dollar sign ($)
  • &euro;: euro sign (€)
  • &pound;: pound sterling sign (£)

Entities for Greek Letters

Entities for Greek Letters

Here are some entities for Greek letters:

  • &alpha;: alpha α
  • &beta;: beta β
  • &gamma;: gamma γ

Entities for Hebrew Letters

Entities for Hebrew Letters

Here are some entities for Hebrew letters:

  • &aleph;: aleph ℵ
  • &beth;: beth ℶ
  • &gimel;: gimel ℷ

Entities for Cyrillic Letters

Entities for Cyrillic Letters

Here are some entities for Cyrillic letters:

  • &#1072;: Cyrillic letter A а
  • &#1073;: Cyrillic letter Be б
  • &#1074;: Cyrillic letter Ve в

Next Topic: HTML Layouts

In our next session, we'll explore HTML Layouts. Layouts define the overall structure and organization of your web pages. Follow us to learn more and master the art of web design!