Hacker News new | ask | show | jobs
by arzke 1072 days ago
> The only way you know that <input /> is acceptable and <div /> isn't, is learning and remembering which elements self-close. It sucks, but that's the way it is.

People remember which elements self-close by repeatedly seeing them written as self-closing tags. So while it indeed makes no difference from the browser standpoint whether you're closing your self-closing tag or not, it can be valuable to beginners.

2 comments

No, people remember which elements self-close by remembering which elements can’t have meaningful content. In the days before XHTML, approximately nobody was confused about the distinction of which elements are self-closing and which have content.
Yet you can still apply styles - to an extent - to most of these. Even just margin/padding will affect many of them.
There's a whole section in the article about the risk to beginners.
Which is the section I am quoting from.