3 ms·
You are also not required to indent code (in most languages); please do if you want me to read it though.
by ZiiS 9mo ago
You are also not required to indent code (in most languages); please do if you want me to read it though.
- dashzebra 9mo agoYou can also indent with spaces and tabs at the same time, who's judging?
- vbezhenar 9mo agoClosing optional HTML tags just adds more ambiguity. How many HTMLParagraphElements here, what do you think? <p> text1 <p> text2 </p> </p>
- have_faith 9mo agoWhy would you nest paragraph tags?
- Hendrikto 9mo agoThey are not nested, according to HTML5 parsing rules. You get 3 (yes, three) sibling paragraphs, including an empty one. There being nesting is just implied by the closing tags and indentation. But it is not actually there. I think this is the point of the example: Adding the closing tags just confuses the reader, by implying nesting that is not actually there, and even introduces a third empty paragraph. It might be better left out entirely.
- hnlmorg 9mo ago2. And there’s no ambiguity there, just invalid HTML because paragraphs aren’t nestable.
- kzrdude 9mo agoIt may look nested but the first p is actually closed when the second p starts, according to https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/p https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/...
- jchw 9mo agoWouldn't this still result in just two paragraph elements? Yes, the first gets auto-closed, but I don't see how a third paragraph could emerge out of this. Surely that closing tag should just get discarded as invalid. edit: Indeed, it creates three: the </p> seems to create an empty paragraph tag. Not the first time I've been surprised by tag soup rules.
- hnlmorg 9mo agoHence why I said “2” ;)
- carlosjobim 9mo agoHTML is more content than programming logic, so it shouldn't be indented.