

Code Guide by @mdo - risons
http://codeguide.co/

======
btown
> Don't include a trailing slash in self-closing elements—the HTML5 spec says
> they're optional.

This kills the XML parser. Yes, I know, you should use a real HTML parser like
BeautifulSoup if you can. But sometimes you don't have one available, or
you're working with legacy tools.

More importantly, if you're looking through the code and you don't know what
tags are self-closing, you can't instantly tell whether something's a syntax
error or not. Off hand, do you know which of the SVG tags are self-closing,
vs. those that permit optional but rarely-used contents? [0] What about the
embed tag? If you make a mistake in rattling off that list, then you cannot
claim that you can read through an arbitrary @mdo-compliant document and know
with certainty whether there is or is not a syntax error. And I'd bet that
many talented frontend developers would make a mistake.

It's an extra character that makes your HTML parse-able by a person or program
that isn't a geek (or the programmatic equivalent thereof) who's read the HTML
spec. And that's well worth the pinky-press.

[0] [http://www.w3.org/TR/html5/syntax.html#foreign-
elements](http://www.w3.org/TR/html5/syntax.html#foreign-elements)

~~~
arnarbi
> More importantly, if you're looking through the code and you don't know what
> tags are self-closing, you can't instantly tell whether something's a syntax
> error or not.

I came to say this, so I'll second you instead. Syntax is less cognitive load
than remembering what element does what - and in reading code, if I don't see
a closing marker I'll go looking for the closing tag before thinking about the
tag.

