News for hackers. Stuff that matters.
Re:Writing HTML by Hand by tannhaeuser on Wednesday September 20, 2023 @03:14AM (#37581306)
Yeah the trailing slash cargo cult just goes to show the author has no idea what he/she is doing. Even more pointless is a pretentious space before the slash. It appears many extant uses of the bogus slash result from WordPress filters and their fragile nature (never change a running WP system aka WP trainwrecks) rather than manual insertion.
Re:Writing HTML by Hand by chrismorgan on Wednesday September 20, 2023 @04:39AM (#37581892)
Mind you, the space before the slash can be load-bearing in HTML syntax, if you use an unquoted attribute value:

  <img src=x/>   =  <img src="x/">
  <img src=x />  =  <img src="x">
Re:Writing HTML by Hand by jraph on Wednesday September 20, 2023 @05:31AM (#37582205)
> Even more pointless is a pretentious space before the slash

It could also be an habit, and not really a harmful one. You can argue against it with convincing arguments, but in the end, there's nothing fundamentally wrong with it. It's understood by the parser.

The space before the slash once was advised for compatibility with old browsers when writing polyglot html. Some old browsers would not understand the slash, but this would not be an issue with a space. This is mostly irrelevant today but habits stick.

And with the gotcha exposed by my sibling comment, maybe it's better to stick with the space after all when using the slash. And I can see how wanting to explicitly close the tag is compelling, even if it has its drawbacks.