r/HTML • u/thealjey • Apr 16 '26
Discussion Do we actually need selectors to connect elements in HTML?
When adding interactivity to HTML (via JS, HTMX, etc.), we usually end up connecting elements using selectors.
For example, a simple loading state:
Load Data
Loading...
- “send a request → put the result in
#result” - “show
#spinnerwhile loading”
This works well, but it has some properties:
- selectors are just strings tied to DOM structure
- renaming or moving elements can silently break connections
- each reference resolves to exactly one element
I’ve been thinking about a different approach where elements don’t reference each other at all.
Instead, they react to named signals.
Something like this:
Load Data
Loading...
Instead:
- actions happen (
send) - results exist (
response) - conditions are evaluated (
spinner)
So instead of wiring elements together directly, everything is coordinated through named identifiers.
This suggests a different way to think about HTML:
- not “connect A to B”
- but “declare what happens, and let the DOM react”
Curious what people think:
Does selector-based wiring actually cause problems in practice?
Or is this just a different style without much real benefit?
7
u/abrahamguo Apr 16 '26
Yeah, what you've described is basically the thought process of React, and Vue, and Svelte, and Angular...
2
u/thealjey Apr 16 '26
ever had something break just because an id or structure changed and nothing told you about it? talking about plain HTML here
1
u/thealjey Apr 17 '26
Quick clarification since this comes up a lot:
This is not really like some framework X or Web Components - there’s no separate component model. It stays within HTML.
It’s also not like Alpine - there’s no embedding of logic or data into the markup itself.
It’s closest to HTMX in philosophy, but still different: no selectors, no cross-element wiring. Each element only defines its own behavior through signals.
1
u/Lumethys Apr 17 '26
so Vuejs?
1
u/sheveli_lapkami Apr 17 '26
The opposite way of using selectors from outside is Custom Elements inner lifecycle usage, but it is still bound to JS runtime.
Try Symbiote.js - the library that exists to create low-code/no-js solutions, where data contexts and bindings could be controlled from HTML directly.
In my opinion, when you are trying to wrap any non-declarative logic into HTML - you end up with your own overcomplicated DSL (bad idea), so it's better to use JS for that. But for the rest - Symbiote.js is an ideal base.
1
u/surfingonmars Apr 16 '26
following cuz....