← Back to context

Comment by eterm

1 day ago

Let's say you forget to close a <b></b> element.

What happens?

Even today, after years of better error messages, the strict validator at https://validator.w3.org/check says:

    Error Line 22, Column 4: end tag for "b" omitted, but OMITTAG NO was specified 

What is line 22?

    </p>

It's up to you to go hunting back through the document, to find the un-closed 'b' tag.

Back in the day, the error messages were even more misleading than this, often talking about "Extra content at end of document" or similar.

Compare that to the very visual feedback of putting this exact document into a browser.

You get more bold text than you were expecting, the bold just runs into the next text.

That's a world of difference, especially for people who prefer visual feedback to reading and understanding errors in text form.

Try it for yourself, save this document to a .html file and put it through the XHTML validator.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <?xml-stylesheet href="http://www.w3.org/StyleSheets/TR/W3C-WD.css" type="text/css"?>
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

    <head>
      <title>test XHTML 1.0 Strict document</title>
      <link rev="made" href="mailto:gerald@w3.org" />
    </head>

    <body>

    <p>
    This is a test XHTML 1.0 Strict document.
    </p>

    <p>
    See: <a href="./">W3C Markup Validation Service: Tests</a>
    <b>huh
    Well, isn't that good

    </p>

    <hr />

    <address>
      <a href="https://validator.w3.org/check?uri=referer">valid HTML</a><br />
      <a href="../../feedback.html">Gerald Oskoboiny</a>
    </address>

    </body>

    </html>

You can have catastrophic parsing errors with the “lax” HTML too. For instance:

    <!doctype html>
    <title>…</title>
    <p>Important: Do <strongNOT</strong> come into the office tomorrow!

Or:

    <!doctype html>
    <title>…<title>
    <p>Important: Do <strong>NOT</strong> come into the office tomorrow!

For reference, observe what happens if you try opening this malformed document in a browser: save it with a .xhtml extension, or serve it with MIME type application/xhtml+xml.

Firefox displays naught but the error:

  XML Parsing Error: mismatched tag. Expected: </b>.
  Location: file:///tmp/x.xhtml
  Line Number 22, Column 3:
  </p>
  --^

Chromium displays this banner on top of the document up to the error:

  This page contains the following errors:
  error on line 22 at column 5: Opening and ending tag mismatch: b line 19 and p
  Below is a rendering of the page up to the first error.

  • Thanks for showing these. We can see Firefox matches the same style of accurate but unhelpful error message.

    Chromium is much more helpful in the error message, directing the user to both line 19 and 22. It also made the user-friendly choice to render up to the error.

    In the context of XHTML, we should also keep in mind that Chrome post-dates XHTML by almost a decade.

    • If, on the other hand, you have some sorts of XSLT errors, Firefox gives you a reasonably helpful error message in the dev tools, whereas Chromium gives you a blank document and nothing else… unless you ran it in a terminal. I’m still a little surprised that I managed to discover that it was emitting XSLT errors to stdout or stderr (don’t remember which).

      Really, neither has particularly great handling of errors in anything XML. None of it is better than minimally maintained, a lot of it has simply been unmaintained for a decade or more.