Re: [EXT] Unclear error message for invalid tags under <html>

On 19/09/2022 22:25, Jason Xu wrote:

For an element that isn't <head> or <body> under <html>, ex.

<!DOCTYPE html>
<html lang="en">
<link rel="stylesheet" href="css/style.css">
<head></head>
<body></body>
</html>

The validator gives a message "Error: Start tag head seen but an
element of the same type was already open." which isn't as clear as
saying something like "Only <head>, followed by <body> is permitted in
<html>".

It may not be as clear, Jason, but it is correct, whereas your paraphrase is not.  Both <head> and <body> elements are permitted within the context of an <html> element, but neither an explicit <head> tag nor an explicit <body> tag are formally required.  For example, the following is (sadly) perfectly valid HTML 5 —

<!DOCTYPE html>
<html>
<title>Appalling coding style</title>
<style>
h1 {text-decoration: underline}
</style>
<h1>Goodbye</h1>

Good authors will, of course, always include explicit <head> and <body> tags, and will explicitly close them, but unfortunately the specification allows authors to be lazy, to omit one or both and also to fail to explicity close one or both.


As an aside, it would be nice if I could open issues and feature
requests in a proper issue tracker instead of a mailing list.

Each to their own — personally I far prefer the simplicity and accessibility of a mailing list.

--
Philip Taylor

This email, its contents and any attachments are intended solely for the addressee and may contain confidential information. In certain circumstances, it may also be subject to legal privilege. Any unauthorised use, disclosure, or copying is not permitted. If you have received this email in error, please notify us and immediately and permanently delete it. Any views or opinions expressed in personal emails are solely those of the author and do not necessarily represent those of Royal Holloway, University of London. It is your responsibility to ensure that this email and any attachments are virus free.

Received on Tuesday, 20 September 2022 08:36:28 UTC