P&G
P&G
P&G
All these are same. Is the use of special entities only for javascript/url?
They do not mean the same thing.
P&G
contains an undefined entity reference &G
, as a validator would tell you. What browsers do with such references is that they are treated literally. If browsers start recognizing new entities, strange things may happen. And they are doing it now, since the added entities as per HTML5 drafts are being added. Incidentally, &G
is not among them.
P&G
is a quite similar case, except that some browsers with broken parsers might incorrectly take the &
part as meaning the & character.
P&G
is a correct notation that stands for P&G.
This has nothing to do with JavaScript, and nothing to do with URLs, any more than HTML document content in general. Ampersands are often needed in URLs, but this does not make the issue a question of URLs. JavaScript code is often written inside a script
element, where special parsing rules may apply, depending on HTML version, but this depends on the content model of the element. (The style
element is a similar case.)