The Forgiving Nature of the Web
HTML and CSS are both extraordinarily relaxed and forgiving. If you forget to close a tag or enter incorrect values in a CSS property, it’s not a big deal, as the parsers continue while ignoring the error. However, that does not mean you have to use these traits intentionally because you are lazy.
When you add JavaScript, it becomes a lot harder. A typo in that code stops execution — nothing after the error runs. But JavaScript is a loosely typed language, so it’s still way more forgiving than the Ada language I was taught at university.
HTML and CSS are both extraordinarily relaxed and forgiving.
This does not mean you have to be sloppy and lazy. Fault-tolerant systems are a backup with robustness built in. That is not an excuse to “don’t bother.”
Sooner or later, you will run into unexpected issues when you try to cut corners. From working in this field for a long time and working with many developers, I can confidently say that if you concern yourself with the details and get it right from the start, you can spend a lot of hours doing something valuable instead of fixing bugs. Trust me, you’ll have enough of those anyway…
Think of it this way. It’s nice to know that you can walk with your shoelaces untied. It’s great that it works, and occasionally, when you forget to tie your shoes, you benefit from that. Still, it’s a good idea to tie your shoes when you put them on.
Therefore, write strict HTML, lint your CSS, and compile your JavaScript to up your game. Don’t rely on fault tolerance to fix your code. You win in the long run.
Resources
- Idiosyncrasies of the HTML parser by Simon Pieters – a free book on how the forgiving error handling was actually specced
- Maintaining Robust Protocols, RFC 9413 – the IETF revisiting Postel’s law: why "be liberal in what you accept" has limits
- Understanding Progressive Enhancement by Aaron Gustafson, A List Apart
- Building a robust frontend using progressive enhancement by GOV.UK
- Resilient Web Design by Jeremy Keith
- 48 Laws, Rules, and Principles of Web Development by Jens Oliver Meiert