Oddbean new post about | logout
 Why do people still put a slash before the closing bracket of an #HTML element that doesn't have a closing tag?

I see it constantly in code examples and not just in old tutorials. Recently, I've been seeing it in documentation for Web Components' custom elements.

As far as I know, this was only ever used in XHTML and was never required in any HTML spec.

The current spec says "it does not mark the start tag as self-closing but instead is unnecessary and has no effect of any kind."

https://html.spec.whatwg.org/dev/syntax.html#start-tags 
 @90ee7ca1 for my own code, I often use XML tools to understand the structure of things, so it's a habit I got into back in "the day" and I've just never stopped. 
 @90ee7ca1 it's also quite good for teaching.

If you don't *know* the intricacies of HTML, then it makes logical sense to write:

`<br></br>` just as you'd write `<p></p>`

or

`<img></img>` just as you'd write `<video></video>`

So showing `<br/>` and `<img/>` helps the learner understand that this element is self closing.