@@ -575,6 +575,49 @@ See also:
575
575
* [Security and privacy are essential] (https://www.w3.org/2001/tag/doc/ethical-web-principles/#privacy)
576
576
* [What data does this specification expose to an origin?] (https://www.w3.org/TR/security-privacy-questionnaire/#underlying-platform-data)
577
577
578
+ <h2 id="html">HTML</h2>
579
+
580
+ This section details design principles for features which are exposed via HTML.
581
+
582
+ <h3 id="attribute-reuse">Re-use attribute names for similar functionality</h3>
583
+
584
+ If you are adding a feature that is specified through an HTML attribute,
585
+ check if there is an existing attribute name on another element
586
+ that specifies similar functionality.
587
+ Re-using an existing attribute name means authors can utilize existing knowledge,
588
+ maintains [consistency] (#consistency) across the language,
589
+ and keeps its vocabulary small.
590
+
591
+ <div class="example">
592
+ The same attribute name, <{select/multiple}> ,
593
+ is used on both <{select}>
594
+ to allow selection of multiple values,
595
+ as well as on <{input}>
596
+ to allow entry of multiple values.
597
+ </div>
598
+
599
+ <div class="example">
600
+ The <{details/open}> attribute was introduced on the <{details}> element,
601
+ and then re-used by <{dialog}> .
602
+ </div>
603
+
604
+ If you do re-use an existing attribute,
605
+ try to keep its syntax as close as possible to the syntax of the existing attribute.
606
+
607
+ <div class="example">
608
+ The <{label/for}> attribute was introduced on the <{label}> element,
609
+ for specifying which form element it should be associated with.
610
+ It was later re-used by <{output}> ,
611
+ for specifying which elements contributed
612
+ input values to or otherwise affected the calculation.
613
+ The syntax of the latter is broader:
614
+ it accepts a space-separated list of ids,
615
+ whereas the former only accepts one id.
616
+ However, they both still conform to the same syntax,
617
+ whereas e.g. if one of them accepted a list of ids,
618
+ and the other one a selector, that would be an antipattern.
619
+ </div>
620
+
578
621
<h2 id="css">Cascading Style Sheets (CSS)</h2>
579
622
580
623
This section details design principles for features which are exposed via CSS.
0 commit comments