Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are HTML character entities necessary?

Why are HTML character entities necessary? What good are they? I don't see the point.

like image 343
Pup Avatar asked Jun 19 '09 02:06

Pup


People also ask

Why does HTML use character entities?

HTML provides special characters, called Entities, which are very useful to display special symbols or to develop web pages in a language other than English. These entities allow browsers to display symbols and not misinterpret them as Markup tags.

Are HTML entities necessary?

You don't generally need to use HTML character entities if your editor supports Unicode. Entities can be useful when: Your keyboard does not support the character you need to type. For example, many keyboards do not have em-dash or the copyright symbol.

What are the character entities in HTML?

HTML character entities are basically a set of characters (entity) used to represent few characters reserved by the HTML, especially invisible characters or characters difficult to type out using a regular keyboard. HTML provides some entity names and entity numbers to use these symbols.

What are entities tag?

An entity tag (ETag) is an HTTP header used for Web cache validation and conditional requests from browsers for resources. Etags use persistent identification elements (PIE) that have been tagged to the user's browser.


2 Answers

Two main things.

  1. They let you use characters that are not defined in a current charset. E.g., you can legally use ASCII as the charset, and still include arbitrary Unicode characters thorugh entities.
  2. They let you quote characters that HTML gives special meaning to, as Simon noted.
like image 160
Matthew Flaschen Avatar answered Sep 22 '22 00:09

Matthew Flaschen


"1 &lt; 2" lets you put "1 < 2" in your page.

Long answer:

Since HTML uses '<' to open tags, you can't just type '<' if you want that as text. Therefore, you have to have a way to say "I want the text < in my page". Whoever designed HTML (or, actually SGML, HTML's predecessor) decided to use '&something;', so you can also put things like non-breaking space: '&nbsp;' (spaces that are not collapsed or allow a line break). Of course, now you need to have a way to say '&', so you get '&amp;'...

like image 27
Simon Buchan Avatar answered Sep 21 '22 00:09

Simon Buchan