What are HTML entities?

Asked

Viewed 540 times

18

I often see some pretty crazy codes in the middle of tags HTML, and searching falls under that term entities, then the doubts arose:

What are Entities HTML and when should I use them?

1 answer

14


It is a code that represents a character, it starts with & and ends with ;. What goes in the middle is the name of the entity, of the character. We can call named characters.

It is mainly used with escape in characters that cannot be easily placed within HTML. A very typical case is the sign of minor and major (< and >) that are used to tags. Quotes also (" and '). Obviously the very & needs to be represented as an entity. Space is another common one since HTML does not consider multiple spaces in sequence as the correct intention and ends up printing only one, thanks to the use of &nbsp; to produce the desired result.

Others are used because they don’t usually have an easy way to represent them by normal means. Mathematical symbols and accentuation are examples. There was a time when this was very important because the source page could be in an encoding that did not allow all possible characters. Today this is rare because it is possible to use Unicode easily, but it is still possible to use it if it is more suitable.

One full and official list.

  • I can use "entities" only in HTML or other technologies can also make use?

  • I don’t know what technologies you’re talking about, but probably only HTML. except if there’s specification that this technology also has.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.