this post was submitted on 20 Jul 2024
583 points (98.2% liked)

Programmer Humor

19704 readers
120 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 12 points 4 months ago* (last edited 4 months ago) (1 children)

It’s not extrapolation on my part, the HTML spec is pretty direct about it:

  1. Then, if the element is one of the void elements, or if the element is a foreign element, then there may be a single U+002F SOLIDUS character (/), which on foreign elements marks the start tag as self-closing. On void elements, it does not mark the start tag as self-closing but instead is unnecessary and has no effect of any kind. For such void elements, it should be used only with caution — especially since, if directly preceded by an unquoted attribute value, it becomes part of the attribute value rather than being discarded by the parser.

https://html.spec.whatwg.org/multipage/syntax.html#start-tags

I don’t think it’s an extrapolation to say that code which is “unnecessary and has no effect of any kind” should be omitted.

And yeah, I linked the MDN docs because they’re easier to read but if they disagree then obviously the spec is the correct one.

[–] [email protected] 6 points 4 months ago* (last edited 4 months ago)

To be annoyingly nitpicky, how is "unnecessary" defined in this context? Whitespace is usually "unnecessary" but I quite like it for readability.

I broadly agree with you though, the W3C spec changes things.