Will HTML 5 validation be worth the candle?

前端 未结 6 763
青春惊慌失措
青春惊慌失措 2020-12-08 07:14

It\'s widely considered that the best reason to validate one\'s HTML is to ensure that all browsers will treat it consistently and predictably.

The HTML 5 draft, h

6条回答
  •  萌比男神i
    2020-12-08 08:07

    W3C HTML5 validator maintainer here. I recently wrote a short “Why Validate?” section for the “About” section of the HTML5 validator:

    http://validator.w3.org/nu/about.html#why-validate

    The source for the text of that section is here:

    https://github.com/validator/validator/blob/master/site/nu-about.html#L160

    And pull requests with suggested refinements/additions are welcome.

    What I have there currently is this:

    The core reason to run your HTML documents through a conformance checker is simple: To catch unintended mistakes—mistakes you might have otherwise missed—so that you can fix them.

    Beyond that, some document-conformance requirements (validity rules) in the HTML spec are there to help you and the users of your documents avoid certain kinds of potential problems. To explain the rationale behind those requirements, the HTML spec contains these two sections:

    • rationale for syntax-level errors
    • rationale for restrictions on content models and on attribute values

    To summarize what’s stated in those two sections:

    • There are some markup cases defined as errors because they are potential problems for accessibility, usability, interoperability, security, or maintainability—or because they can result in poor performance, or that might cause your scripts to fail in ways that are hard to troubleshoot.
    • Along with those, some markup cases are defined as errors because they can cause you to run into potential problems in HTML parsing and error-handling behavior—so that, say, you’d end up with some unintuitive, unexpected result in the DOM.

    Validating your documents alerts you to those potential problems.

提交回复
热议问题