⇧
vadnica-logo
Editor My Blog Password Manager Finance My Services About the Project Telegram O meni O meni

HTML Entities

Reserved characters in HTML must be replaced with character entities. If we use the less than < or greater than > signs in text, the browser will likely confuse them with tags. When we want to write in text form, the text will be displayed as the element we used. If we use entities, it looks like <span></span> and can be presented in text form. To display the < sign, we must use &lt; or &#60;. Not all browsers may support all entities, so it makes sense to check before uploading to the web. A frequently used entity in HTML is the non-breaking space &nbsp;. A non-breaking space is a space that does not go into a new line. Two words separated by a non-breaking space will stick together (they will not break into a new line). This is handy when a line break is disruptive, and we want to avoid it.

    If we write a sentence with multiple       spaces, the browser collapses them into one.
  1. Without entities: If we write a sentence with multiple spaces, the browser collapses them into one.
  2. If&nbsp;we write a sentence with multiple&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;spaces, we get the actual spacing.
  3. With entities: If we write a sentence with multiple       spaces, we get the actual spacing.
EXAMPLE
RESULT

Commonly Used HTML Entities

A common use of the non-breaking space is to prevent browsers from collapsing spaces on HTML pages. If we want to add five or more spaces to the text, the browser will delete 4, so we can use the entity &nbsp;. Since using entities is simple, I won't add an example for each one individually, but I will list them all in a table.

Result Description Entity Name Entity Number
  Non-breaking space &nbsp; &#160;
< Less than &lt; &#60;
> Greater than &gt; &#62;
& Ampersand &amp; &#38;
" Double quotation mark &quot; &#34;
' Single quotation mark &apos; &#39;
¢ Cent &cent; &#162;
£ Pound &pound; &#163;
¥ Yen &yen; &#165;
€ Euro &euro; &#8364;
© Copyright &copy; &#169;
® Registered trademark &reg; &#174;
≤ Less than or equal to &le; &#8804;
≥ Greater than or equal to &ge; &#8805;

Combining Diacritical Marks

A diacritical mark is a "glyph" added to a letter. Some diacritical marks such as (  ̀ ) and (  ́ ) are called accents. Diacritical marks can appear above or below a letter, inside a letter, and between two letters, and can be used in combination with alphanumeric characters not present in the character set. Let's look at some examples:

  1. To display è we type e&#768;
  2. To display ó we type o&#769;
  3. To display a circumflex  ̂  we type &#770; or for â we type a&#770;
  4. To display a tilde   ̃  we type &#771; or for õ we type o&#771;

All that is required is to type the letter we want to apply the specific mark to before the diacritical mark.