4 ms·
The optional form is weird looking coming from the XHTML era where we were trained on the auto-closing form. Looking up elements that support no closing tag:
by pests 3y ago
The optional form is weird looking coming from the XHTML era where we were trained on the auto-closing form.
Looking up elements that support no closing tag:
html, head, body, p, li, dt, dd, option, thead, th, tbody, tr, td, tfoot, colgroup
Makes sense if you think about it. Basically everything is pretty well defined and its obvious what next tag should close the context. <td> for example obviously ends when you come across another <td>, another <tr>, or the required </table>
- pbhjpbhj 3y ago><td> for example obviously ends when you come across another <td>, another <tr>, or the required </table> // Only a madman would nest tables!! /me crying in 2000's web design.
- pests 3y agoNope, nesting works! The required ending tag on table means any nested table will open a new context and then any <tr> or <td> will now scope to that table and will until the second tables closing </table>. <table> <tr> <td> <table> <tr> <td> table-cell-inside-table </table> </table>
- MrVandemar 3y agoI lived through the XHTML era; when I was doing web-design I adopted it for many projects. It just seemed right to rigorously enforce a formal approach, and I suspect it reduced errors. Took me a long time to train myself out of <br/> afterwards though. But the optional-style works I think for writing. Especially if you're just writing a document. If you don't have site-menus, a search bar, social-media sharing icons, javascript libraries and all the other paraphenalia and page-furniture of a website, then you are left with a lean and structured file.
- foobarbecue 3y agoYou mean </br>, presumably.
- throwaway_no 3y ago<br /> is a self closing tag. This is used in XML / XHTML for elements that have no contents. It is a valid short form of <br></br>
- thinkingemote 3y agotechnically <br></br> is not allowed to have an end tag in the HTML spec https://developer.mozilla.org/en-US/docs/Web/HTML/Element/br https://developer.mozilla.org/en-US/docs/Web/HTML/Element/br so it should be <br> on its own or <br />
- naniwaduni 3y agoA silly corner of the spec, considering that this is a spec that specifies exactly how to handle e.g. misnested elements and admits plenty of other things that read intuitively as standardized sloppiness.
- midasuni 3y agoNo. <br></br> is shortened to <br/>
- deleted 3y ago[deleted]
- foobarbecue 3y agoWow, thanks everyone... it seems I've misunderstood this all these years.
- pests 3y agoYou see this a lot in React/JSX too. Saves seme typing and noise inserting a component with no children.
- deleted 3y ago[deleted]