Tidy 4

From Htmlpedia
Jump to: navigation, search

Tidy: unescaped & should be written as &

Cause:

The ampersand ("&") is a special character in HTML. It marks the beginning of a entity, like "&nbsp" for a non-breaking space.

In XHTML, a entity must also end with a semicolon (";"), as in " "

Because of this, any time a literal ampersand appears in a document, it must be written as the character entity "&". Ampersands commonly appear in the query string of a URL, and must be expressed as an entity in that context.

Example - Normal Ampersand:

BadSmith & son
GoodSmith & son

Example - Ampersand in a Query String:

Bad<a href="http://www.domain.com/cgi?x=1&y=2">query string</a>
Good<a href="http://www.domain.com/cgi?x=1&amp;y=2">query string</a>

Solution:

Replace "&" with "&amp;".

References: