HTML is Weird
by Stephen Fluin
I've been struck a few times in the past few months by how truly weird
HTML is. Perhaps most developers already know this, but coming from an era where HTML used to the wild west, some of this was surprising to me.
Forget Close Tags##
You probably know you don't need to (and shouldn't) close tags like
. Did you know that you don't have to close
tags, as long as it's semantically unambiguous? That's right, that wall of
at the end of your page are completely unnecessary.
I would still recommend you close all of your tags, even if it is valid standards-compliant HTML. Otherwise it can be very hard to figure out what's going on.
Forget Tags Entirely##
There are a few tags that can be omitted completely. In certain circumstances, even the most standard tags such as
Check out the W3C spec on optional tags
I'm showing my age through these memories, but gone are the days where constantly there were new HTML tags providing new capabilities. There's now a standard list of HTML elements that all of the browsers agree on. Anything not on this list ends up extending
. Each of these tags has a predefined allowable attributes. All of the browsers agree and we don't often see new elements. All of the HTML element innovation has moved into projects like Angular and Custom Elements HTML standards.