In HTML, a &
marks the begin of a reference, either of a character reference or of an entity reference. From that point on, the parser expects either a #
denoting a character reference, or an entity name denoting an entity reference, both followed by a ;
. That’s the normal behavior.
But if the reference name or just the reference opening &
is followed by a white space or other delimiters like "
, '
, <
, >
, &
, the ending ;
and even a reference to represent a plain, &
can be omitted:
<p title="&">foo & bar</p>
<p title="&">foo & bar</p>
<p title="&">foo & bar</p>
Only in these cases can the ending ;
or even the reference itself be omitted (at least in HTML 4). I think HTML 5 requires the ending ;
.
But the specification recommends to always use a reference like the character reference &
or the entity reference &
to avoid confusion:
Authors should use "&
" (ASCII decimal 38) instead of "&
" to avoid confusion with the beginning of a character reference (entity reference open delimiter). Authors should also use "&
" in attribute values since character references are allowed within CDATA attribute values.
for example, I don't think this "validator" is correct.