When Web browsers were invented, the programmers recognized that there was a possibility that there would be hundreds if not thousands of people writing HTML and creating Web pages. When this many people (and there are significantly more than that now) are trying to use a programming language or markup language like HTML, it can get very frustrating very quickly if every tiny error results in a broken page. So the Web browser programmers decided that browsers should be forgiving.
What this means is that when a Web browser views a Web page, it has the rules for HTML (and CSS and JavaScript) and attempts to interpret them to display your Web page. But if it comes across something unexpected, incorrect, or from an older specification, the browser ignores it or tries to guess at what the designer wants.
This means that a novice or lazy designer can get away with incorrect code and have pages that display in the browser window without a problem. Some errors are minor, such as leaving off the alt attribute in an image tag. Technically, this is invalid, but the browser displays the image anyway. Some errors are bigger, such as leaving off the closing table tag. In older versions of Netscape, before it got more forgiving, this would cause a table and everything after it in the HTML, to simply disappear. While that is noticeable, Internet Explorer didn't mind the missing table tag and would display the page. So many designers who did this wouldn't test in Netscape and wouldn't know of the problem for long periods of time.
So Why Bother with Valid HTML?
While browsers will attempt to display your HTML even if there are errors, there are some good reasons to validate your HTML:
- While the HTML may display, it may display differently than if it were written correctly.
- Errors will compound with one another. One error may display fine, two might have a slight problem, and 5-10 might cause the page to display completely incorrectly.
- While most modern browsers are forgiving, newer user agents like cell phones, PDAs and so on may not be as forgiving. Broken pages will lose you readers.
- Invalid HTML, especially if it's been deprecated, may not be supported by browsers in the future. So, while the tag works right now, future browsers might not support it, and then your pages using that tag will no longer work.
It's good that you're testing your Web pages in a Web browser, but validating the HTML and CSS will help you make pages that stand the test of time and new browsers.