Anatoly Bubenkov
Anatoly Bubenkov

Reputation: 696

HTML Symbols magic

just realized that html symbols like:

&

will be also recognized by browser WITHOUT

;

I had problem because of that:

&current

was replaced with

¤t 

can you clarify - why?

Upvotes: 4

Views: 411

Answers (3)

Alohci
Alohci

Reputation: 83051

Some named character references are, for backward compatibility reasons, recognised without needing a trailing semicolon. &curren is one of them.

A full list of named character references, which shows those that don't need a trailing semicolon is given here: https://www.w3.org/TR/html51/syntax.html#named-character-references

Upvotes: 2

alex
alex

Reputation: 490481

Because any & in HTML should be encoded as &. So any & on its own will be interpreted as the start of a HTML entity and browsers attempt error correction (the parser may attempt to interpret the entity if a character falls outside of its allowable sequence, such as the space character).

Whenever you use a & in your HTML, encode it as &.

Upvotes: 3

Ernest Friedman-Hill
Ernest Friedman-Hill

Reputation: 81724

Browsers try hard to make sense of garbage when they can. There's no rule that says they should do this, or that they have to, or even that it's a good idea. But if some browsers do this, then they just do.

Upvotes: 1

Related Questions