Q:

html - What are entities for?

In HTML, entities such as &gt; and &lt; are used to type things in HTML like "<b>Hello world!</b>" using &lt;b&gt;Hello world!&lt;/b&gt;.
But what is the point of HTML entities? Why isn't it like Javascript where you can just place backslashes in front of <, >, etc. Like why can't HTML entities be much simpler so that you can type "<b>Hello world!</b>" using \<b\>Hello world!\</b\>? Then wouldn't it be more readable with \<b\>Hello world!\</b\> instead of &lt;b&gt;Hello world!&lt;/b&gt;?

A:

Entities aren't just for escaping special characters. In some settings, you can use entities to transclude snippets of markup.
For example, take a look at how Mozilla has built its error pages:
http://mxr.mozilla.org/mozilla-central/source/docshell/resources/content/netError.xhtml#348
&securityOverride.linkText; is an entity reference. That entity is defined here:
http://mxr.mozilla.org/mozilla-central/source/browser/locales/en-US/chrome/overrides/netError.dtd#180
In this usage, they've separated the lanuage-dependent strings from the logic and structure of the page, which works well for localization.
In another example, known as the "billion laughs," a series of entities reference each other in order to produce a billion copies of the word lol in just a few lines of code.

