Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New principle: Discourage overloading (in HTML) #370

Closed
LeaVerou opened this issue May 16, 2022 · 4 comments · Fixed by #502
Closed

New principle: Discourage overloading (in HTML) #370

LeaVerou opened this issue May 16, 2022 · 4 comments · Fixed by #502
Assignees
Labels
Agenda+ Status: Consensus to write We have TAG consensus about the principle but someone needs to write it (see "To Write" project) Status: In Progress We're working on it but ideas not fully formed yet. Topic: HTML

Comments

@LeaVerou
Copy link
Member

This was brought up by @hober in a breakout today.

We should have a principle about avoiding things like <input type> in the future.

@LeaVerou LeaVerou changed the title New principle: Discourage overloading (in HTML version) New principle: Discourage overloading (in HTML) May 16, 2022
@plinss plinss added this to the 2022-06-06-week milestone May 19, 2022
@LeaVerou
Copy link
Member Author

Consensus from today's breakout:

  • If we were to design <input> today, text fields would still be grouped under the same element (<text> or <textfield> or the like), but radios, checkboxes, color inputs, file inputs would have likely been separate elements.
  • <object> is a total mess: can cause plugin execution, or subresource loading & rendering, or some other behavior.
  • <link rel>: some things should have been grouped together, others should have been separate elements, because some rel values cause subresource loads and others don't
  • <button> is a positive example of overloading where type differentiates different purposes, but they are all similar enough and have the same API.
  • <textarea> possible it should have been overloaded together with single line text fields, as some kind of <text multiline>. we've seen cases where people have wanted to grow <textarea> to have features like pattern="", which suggests it should have been the same element as single-line text input.

@hober hober added Status: In Progress We're working on it but ideas not fully formed yet. Status: Consensus to write We have TAG consensus about the principle but someone needs to write it (see "To Write" project) labels Jul 27, 2022
@torgo torgo modified the milestones: 2022-06-06-week, 2022-10-03-week Oct 2, 2022
@hober
Copy link
Contributor

hober commented Nov 7, 2022

see also #270 (comment)

@martinthomson
Copy link
Contributor

Checkboxes and toggle/switch are a good case where the new UX treatment of the toggle gains some benefit from a fallback.

We have also given advice in the past that <input type="somenewthing"> degrades cleanly to a text field. Overloading might have been a good thing. On the other hand, with some JS, you can polyfill just about anything and maybe the transitionary costs are not what should dominate.

martinthomson added a commit that referenced this issue Jul 15, 2024
I'm sure that we could say more, but I think that this is enough.

Closes #370.
@LeaVerou
Copy link
Member Author

LeaVerou commented Dec 4, 2024

Thinking about this some more in today's meeting, the crux of it is avoiding mode errors: <input> and <link> are antipatterns because they have attributes that only apply when other attributes are set, or properties that make sense only when other properties have certain values. When this is not an issue, it's fine to reuse elements, e.g. reusing checkboxes for switches is fine.

So perhaps what we really need is a principle around mode errors, since that applies to other cases too, e.g. in CSS when we introduce properties that only have meaning when other properties are set it always ends up being a source of author pain (though sometimes unavoidable — but principles are rules of thumb, not laws).

Edit: I ended up filing a new issue: #532

martinthomson added a commit that referenced this issue Dec 4, 2024
I'm sure that we could say more, but I think that this is enough.

Closes #370.
martinthomson added a commit that referenced this issue Dec 4, 2024
I'm sure that we could say more, but I think that this is enough.

Closes #370.
hadleybeeman pushed a commit that referenced this issue Dec 4, 2024
* Establish a rule about element overloading

I'm sure that we could say more, but I think that this is enough.

Closes #370.

* Add some divs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Agenda+ Status: Consensus to write We have TAG consensus about the principle but someone needs to write it (see "To Write" project) Status: In Progress We're working on it but ideas not fully formed yet. Topic: HTML
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants