-
Notifications
You must be signed in to change notification settings - Fork 47
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: Guidance on when to use a child element vs an attribute #270
Comments
We discussed today and agreed we should pick this up and do something. |
Yeah, I debated whether I should have in the first place, sorry. I ask whether it is potentially related to #213 because very often microsyntaxes are trying to stuff complex structured information into an attribute. Elements allow structure, but are often unappealing or of debatable fit. Seems potentially worth considering them together as you craft advice. Regarding #298 - there has been a lot of discussion among implementers and feelings about mistakes in the past created. An example of this, potentially, is the |
From today's breakout:
|
I'm not sure I agree that Same deal with |
The action is on me to draft text for this one. |
Related to: #269
We should add some guidance for people designing HTML elements (both spec writers and web component authors) about when to choose an attribute for metadata vs a specific element type.
Some examples of child elements being used for metadata instead of attributes are:
<caption>
for<table>
<figcaption>
for<figure>
<legend>
for<fieldset>
<source>
for<video>
,<audio>
,<picture>
<summary>
for<details>
<title>
and<desc>
in SVGI think we should encourage use of child elements over attributes for any text that will be presented to end users. Child elements can include HTML for inline markup, as well as i18n attributes (
dir
,lang
etc).There are examples in the web platform that violate this guideline:
<img alt>
title
attribute<input placeholder>
<input value>
<optgroup label>
Should these be presented as past design mistakes or should the principle become more granular somehow to accommodate them? E.g. perhaps this doesn't apply to replaced elements? On a related note, this guidance cannot be followed for empty elements, which means it cannot be followed for new global attributes. Should new empty elements be discouraged?
Child elements of a specific type are also a way to annotate elements with metadata of a more complex data structure than text, numbers, or booleans (or short lists thereof, like in the
class
attribute). Examples of such complex data structures that are already specified via child elements are<source>
and<option>
which essentially specify lists of objects (in JSON terms).(I'm fine to send a PR for this once there's consensus about adding the principle and what it should be)
The text was updated successfully, but these errors were encountered: