7 ms·
> Also remember that there are a few common elements, like <p> and <li>, that you usually don't need to close. <p> and <li> don’t ever need to be closed, do th
by bentley 3y ago
> Also remember that there are a few common elements, like <p> and <li>, that you usually don't need to close.
<p> and <li> don’t ever need to be closed, do they? Closing would only be necessary if leaving them open would introduce ambiguity, but it never does.
- mikae1 3y agoNope. But if you don't use a closing tag and put, say, an <img> tag below a <p>, the image will be child of the paragraph. Perhaps that's not always what you want.
- toyg 3y agoCries in XHTML Close your tags, people. Make your intent non-ambiguous. It's basic hygiene.
- AlienRobot 3y agoIt's a paragraph, not a div, the intent is clear by definition.
- toyg 3y agoThe intent at the beginning of the paragraph, but not at the end. Is an IMG meant to be in the paragraph? Is a SPAN? They are inline elements that can indeed be inside a P. I honestly don't understand this level of laziness in 2023. Editors close tags automatically, ffs. For the sake of saving a keystroke or two we end up with unintuitive and ambiguous crap.
- bentley 3y agoIf I didn’t intend the img or span to be in the paragraph, I would have closed the <p>. The act of leaving the <p> open is what demonstrates that my intent is for the img to remain inside.
- toyg 3y agoAnd now you have a tag that is sometimes closed and sometimes open, forcing me to scan the entire document to figure if you've ever closed this bloody thing - as opposed to knowing that you will eventually close it, and that anything I see until then is inside the P.
- AlienRobot 3y agoYou won't need to scan the entire document because pretty much anything can make the P tag close, including closing the element containing it.
- bentley 3y agoDo you always specify <tbody> in your tables?
- naasking 3y agoI do.
- toyg 3y agoI always have the right amount of well-formed (and well-spanned) TD and TR, making my markup actually logical and simple to understand. Which is not the result we get from open P.
- bentley 3y agoI stopped closing <td> and <tr> because I found the (completely valid, completely unambiguous) practice of dropping the closing tags dramatically reduced the visual noise and clutter, making it easier for me to read my own tables.
- toyg 3y agoIf you say so, de gustibus. You might be making life marginally easier for you, to the detriment of any tool (or person) that has to parse your output.
- mock-possum 3y agoDo you not??