DEV Community

Christian Fried
Christian Fried

Posted on

HTML validation - pros and cons ⚖️

This is an update to my question if you really need to validate HTML. This time I asked ChatGPT about it 🤖 and edited out the weakest points.

HTML validation, or HTML conformance checking, involves checking whether a web page complies with the specifications defined by the HTML standard. Here are some pros and cons of HTML validation:

Pros

  1. Cross-browser compatibility: Valid HTML code is more likely to be displayed consistently across different web browsers. This helps ensure a uniform user experience.
  2. Future-proofing: Following HTML standards makes your code more resilient to future changes in web technologies. It helps your website remain compatible as browsers evolve.
  3. Improved accessibility: Valid HTML often leads to better accessibility. Properly structured HTML with semantic elements contributes to a more accessible and inclusive web experience for users with disabilities.
  4. Search engine optimization (SEO): Search engines may favor well-structured and valid HTML, potentially improving the search engine ranking of your web pages.
  5. Debugging and maintenance: Valid HTML is generally easier to debug and maintain. It helps identify errors and inconsistencies in the code more quickly.
  6. Consistency and readability: Valid HTML promotes consistency in code formatting and enhances code readability, making it easier for developers to collaborate and maintain the codebase.

Cons

  1. Strict enforcement challenges: Strict validation can sometimes be challenging, especially when dealing with third-party plugins, browser-specific features, or experimental technologies that may not adhere strictly to HTML standards.
  2. Learning curve: For beginners, strict adherence to HTML standards might pose a learning curve. Some may find it restrictive, especially when trying to experiment with cutting-edge web technologies.
  3. Real-world tolerance: The real-world web often involves imperfect HTML due to various reasons, such as browser quirks, legacy code, or the need for quick fixes. Strict validation might not always align with practical considerations.
  4. False positives and negatives: Validation tools may generate false positives or false negatives, flagging code as invalid when it works or vice versa. This can be frustrating for developers and may lead to unnecessary adjustments.

(I removed cons about performance - Chat GPT even said it was not a problem - and resource intensiveness - that doesn't seem to be a problem, either.)

In (Chat GPT's) summary, HTML validation can offer several benefits, such as improved cross-browser compatibility, accessibility, and future-proofing. However, it comes with challenges related to strict enforcement, potential performance impact, and the need to balance standards with real-world considerations. Developers often need to find a pragmatic approach that aligns with the goals of the project and the needs of its users.

It seems there are benefits to validating. What do you think? Do you validate your HTML? Do you validate your CSS?

Top comments (3)

Collapse
 
nerdfiles profile image
nerdfiles • Edited

being able to submit resources by URI at all is a technological achievement that promotes studyability, improvability, and changeability; i.e., a collaborative ethos around social facts (like nutrition facts), which is why we once saw it as an achievement worthy of supplying as a feature at the footer of our websites.

Collapse
 
cfried profile image
Christian Fried

Care to explain? What's the link with validation?

Collapse
 
nerdfiles profile image
nerdfiles

the link with validation is interoperability. if your webpage cannot be studied by the w3c validator, [for example], it's not studyable in a fundamental way (in the sense of what the web [is]).

"The WWW is fundamentally a distributed hypermedia application." - Richard Taylor.

"Hypermedia is defined by the presence of application control information embedded within, or as a layer above, the presentation of information."" - Roy T. Fielding