Re: Error Message. & did not start a character reference. (& probably should have been escaped as &.)

2013-10-26 23:43, David Dorward wrote:

> On 26 Oct 2013, at 1:27, CEO nativapps wrote:
>> I was checking www.nativapps.com and the W3C checker give me this error:
>>
>> & did not start a character reference. (& probably should have been
>> escaped as &.)
>>
>> This is not an error
>
> Yes, it is.
>
>> because we are using href
>
> That makes no difference. You are representing the URL in an HTML
> document not in plain text. & should be expressed as &.

That was/is the rule in HTML 4.01, but the page has <!DOCTYPE html>, so 
it is validated as HTML5. The rules of HTML5 have changed during the 
years, but the current wording allows a naked “&” in an attribute value 
if it is not followed by an identifier that is the name of a named 
character reference. This is in accordance with browser practices.

The validator is now in error in this issue, but its authors seem to 
refuse to fix it, since they think that the “specification” (HTML5 
draft) should be fixed instead.

In practice, you can ignore these error messages. Alternatively, replace 
“&” by “&amp;”. It’s *allowed* in HTML5 too to always represent the “&” 
that way. The downside is that the attribute values look a bit more 
messy, and there is always a risk of making mistakes when doing 
replacements like that.

Yucca

Received on Saturday, 26 October 2013 21:26:54 UTC