jaffathecake,
@jaffathecake@mastodon.social avatar

We use self-closing syntax in HTML where it doesn't do anything. People see it and assume it does something.

Why do we keep doing this to ourselves?

https://www.reddit.com/r/webdev/comments/1cceb03/i_thought_i_knew_html_until_i_saw_this/

thet,
@thet@graz.social avatar

@jaffathecake it's more explicit, which is good and would theoretically be easier to parse except parsers cannot really on it because HTML is so forgiving and people exploiting that.

jaffathecake,
@jaffathecake@mastodon.social avatar

@thet I agree that it would be nice if the syntax actually worked, but it doesn't https://jakearchibald.com/2024/attributes-vs-properties/

schizanon,
@schizanon@mastodon.social avatar

@jaffathecake maybe because it (usually) doesn't do any harm

jaffathecake,
@jaffathecake@mastodon.social avatar

@schizanon except that case

schizanon,
@schizanon@mastodon.social avatar

@jaffathecake an empty paragraph seems pretty unusual to me, but I predate JSX.

colby,
@colby@kosmos.social avatar

@jaffathecake because, while being much maligned in the last decade, XML got something right, and it's this part of the spec. HTML's self-closing behavior is obscure and confusing and hazardous.

Hixie should have fixed this in HTML5 to allow authors to opt in to the sane thing without going full-on XHTML (not that there's anything wrong with that; cf <https://www.nayuki.io/page/practical-guide-to-xhtml>).

primalanomaly,
@primalanomaly@mastodon.social avatar

@jaffathecake this is just some noob who doesn’t know how p tags work. Although in their defense, the closing of html tags is quite wildly inconsistent, with all sorts of different rules for different elements.

flpvsk,
@flpvsk@mastodon.social avatar

@jaffathecake consistency, maybe? from a mental load standpoint the idea that we should close all the tags is simpler than remembering which tags we should and shouldn't close.

Another instance where something that was meant to simplify writing code ends up making it harder.

tomw,
@tomw@mastodon.social avatar

@jaffathecake I'll never stop writing <br />

sil,
@sil@mastodon.social avatar

@jaffathecake Could be react-thinking bleeding through into HTML, perhaps. Enough people have joined the industry as a "react-first" engineer (maybe a "framework-first", I don't know if other frameworks do this) that they learned All Tags Must Be Closed And All Tags Can Be Self Closing, perhaps?

keul,
@keul@fosstodon.org avatar

@sil @jaffathecake not the only reason.
Who is old enough here lived in the XHTML age, when suddenly XML/HTML was the way to go (especially here in Italy, for an old accessibility act).
Also nowaday, when I write ye-olde plain HTML I still self close some tags because I used to do it for years.

jaffathecake,
@jaffathecake@mastodon.social avatar

@keul @sil I'm less convinced by that, because folks don't do checked="checked" anymore, which was required by XHTML.

jamesh,
@jamesh@aus.social avatar

@jaffathecake @keul @sil does the JSX syntax used by React require that syntax for empty elements? Maybe they cargo cult that into the actual HTML.

jaffathecake,
@jaffathecake@mastodon.social avatar

@jamesh @keul @sil yes it does

ppk,
@ppk@front-end.social avatar

@jaffathecake Because front-end engineers should appear much more complicated than it actually is. That's the theme of the past 15 years.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • PowerRangers
  • thenastyranch
  • Youngstown
  • hgfsjryuu7
  • slotface
  • rosin
  • ngwrru68w68
  • InstantRegret
  • kavyap
  • osvaldo12
  • everett
  • DreamBathrooms
  • mdbf
  • magazineikmin
  • anitta
  • Durango
  • khanakhh
  • tacticalgear
  • vwfavf
  • ethstaker
  • GTA5RPClips
  • modclub
  • cubers
  • tester
  • cisconetworking
  • Leos
  • normalnudes
  • provamag3
  • All magazines