← Back to context

Comment by jraph

10 hours ago

At this point, closing slashes for void elements is coding style, exactly like white space we use for indentation. You can't be right because this is in opinion territory. Exactly like whether one should put semicolons or not in JavaScript when you have automatic semicolon insertion. Some people have strong opinions on the matter. Putting them has drawbacks, and not putting them too, and in both cases, readability and clarity, which is subjective, is a factor.

You are right that it has drawbacks and that it can bite. OTOH, people using closing slashes usually also quote all their attributes and will virtually never be bitten by this.

But people have backgrounds and habits, there's culture around a language like HTML, and these backgrounds are cultures have been shaped by XHTML.

Whether to put or not to put the slash is a healthy conversation to have and there are valid points for both, but if you are arguing like you are doing here for HTML5, considering "they don't bother to understand", you'll lose your arguments and people will find you annoying.

Some people feel bad about not closing br with a slash because it kinda feels like unmatched parentheses, or old malformed HTML from the 90's. That's not reasonable, but for the better or the worse, you can't just ignore this.

Some people sometimes write XML, and when they switch to HTML, their XML habits are there, and following habits especially when they are mostly harmless is efficient.

Some people write polyglot (X)HTML for some reason, and there the slash is needed.

There are reasons to put the slash, like there are reasons not to write it, and you can't just impose your truths like this.