HTML entities are special codes that are used to display reserved characters or characters that have special meaning in HTML.

These characters include things like angle brackets,ampersands,andquotation marks.

Use of HTML Entities

The use of HTML entities ensures that these characters are displayed properly on a web page, even if they would otherwise be interpreted as HTML code.

For example, the ampersand character(&)is used to start an HTML entity, so if you want to display an ampersand on your page, you need to use the entity code (&).

Here are a few examples of commonly used HTML entities:

  • <less than symbol.
  • >greater than symbol.
  • &ampersand.
  • ""quotation mark.
  • ''apostrophe.

For example, to display the text "The less than sign is < and the greater than sign is >", you can use the following HTML code:

<p>The less than sign is <strong>&lt;</strong> and the greater than sign is <strong>&lg;</strong></p>

This will be displayed in the browser as:

The less than sign is < and the greater than sign is >

Non-breaking Space:

A non-breaking space is a special character that looks like a regular space but is used to prevent line breaks between words or elements that should be kept together.

In HTML, a non-breaking space can be represented by the entity &nbsp;or the Unicode character \u00A0.Here's an example:

Example

<!DOCTYPE HTML>
  <html>
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet"  href="style.css"/>
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <title>Title of the Document</title>
    </head>
    <body>
      <p>My name is John&nbsp;Doe.</p>
    </body>
</html>

In this example, the non-breaking space is used between "John"and "Doe"to ensure that they stay on the same line and are not separated by a line break.

Combining Diacritical Marks:

Combining diacritical marks are special characters that can be placed over or under other characters to modify their pronunciation or meaning.

In HTML, combining diacritical marks can be represented by Unicode characters or the corresponding HTML entities.

Example

<!DOCTYPE HTML>
  <html>
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet"  href="style.css"/>
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <title>Title of the Document</title>
    </head>
    <body>
      <p>The word "naïve" contains a combining diaeresis: &#239;.</p>
    </body>
</html>

In this example, the combining diaeresis (¨)is used to modify the pronunciation of the letter "i"in the word "naive."

The combining diaeresis is represented by its Unicode character (\u0308)and is combined with the letter "i" using the HTML entity&#239;or the Unicode character (\u00EF).

Entities are very inportant while creating a web site and it will gives you more opportunity to have some easy symbols on it. let see what Symboles is in the next chapter.