W3C home > Mailing lists > Public > www-validator@w3.org > May 2018

Re: How tags are reported

From: David Dorward <david@dorward.me.uk>
Date: Tue, 29 May 2018 16:27:37 +0100
To: "Mike McCutcheon" <mike@around-the-world.co.uk>
Cc: www-validator@w3.org
Message-ID: <83372201-0884-4ADA-83FF-71B301AC2FBD@dorward.me.uk>
On 28 May 2018, at 20:16, Mike McCutcheon wrote:

> This is presumably because my php code uses the htmlspecialchars() 
> function
> to convert the predefined characters "<" and ">" in the stored email 
> into
> HTML entities.

> Is that OK or should the validator report errors to me ? For example, 
> is the
> validator only saying the HTML is error-free because it doesn't 
> recognize
> some of it as HTML because the tags have been converted ?

The validator will correctly interpret `&gt;` as the HTML code for "Show 
a greater than sign here" (and so on for other entities).

If you are putting that somewhere that is allowed, then it will be 
valid.

     <div>&gt;</div>

If you are putting it somewhere forbidden, then it will report an error.

     <div &gt;></div>

*Attribute `&gt;` not allowed on element div at this point.*

If you write an HTML document which contains the HTML to express the 
source code of another (invalid) HTML document as part of the 
document…

     <!DOCTYPE html>
     <meta charset="utf-8">
     <title>For example</title>
     <div>
         &lt;!DOCTYPE html>
         &lt;p>Invalid HTML because the title is missing
     </div>

… then it will tell you the document is valid.

It will not attempt to validate the HTML document being rendered by the 
HTML.

i.e.

     <!DOCTYPE html>
     <p>Invalid HTML because the title is missing

… will not be tested for validity as an HTML document in its own 
right.
Received on Tuesday, 29 May 2018 15:28:07 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:00:04 UTC