When the specific tags and codes contained in a HyperText Markup Language (HTML) document all conform to the proper standards set by the organization that maintains the standard, that document is said to contain valid HTML code. A document that contains valid HTML should be viewable by any program or web browser that has accurately implemented the HTML language standard. This provides a baseline for compliance that gives firm guidelines for those creating HTML documents and for companies or people who are developing applications to view or process those documents. While a clear standard exists for HTML, it is not always followed and is sometimes unofficially extended, allowing the creation of documents that might rely on features not implemented in all or even most web browsers.
There are many benefits to having a document that contains only valid HTML. The largest is that there is a clear definition of how the different tags and code should operate, giving the designer a predictable framework within which to work. This same strict definition helps developers of applications that use valid HTML to have an unambiguous blueprint on how to handle the different aspects of the language and how to handle exceptions to language so errors can be caught and processed in a structured way. This assists in both the creation and debugging of HTML documents.
Another benefit to using valid HTML documents is that all users who are attempting to view a page, no matter what device they are using, will be able to experience the website in the exact same way if they are using a compliant browser. Several mechanisms exist within the HTML standard that can account for different situations so users with accessibility problems or who are using new devices will be able to, at a minimum, view the essential parts of a web page. This means a page that employs only valid HTML can potentially have a wider user base, because all compliant applications will be able to display it.
Despite the HTML standards that have been produced, there are still many designers and developers who implement the standard incorrectly or intentionally include support for invalid HTML code. One reason this can occur is that a certain glitch in a browser creates a desirable result, such as breaking otherwise standard formatting, when invalid code is used. It also can come about because of the use of non-standard tags or elements that grow in popularity despite their invalid nature. One problem with designers using invalid HTML code is that not all devices will support it and, eventually, the bugs or invalid code could stop being supported altogether, forcing designers to rewrite an entire website so it uses valid HTML.