Skip to content

Commit eaf5072

Browse files
hoberLeaVerou
andauthored
New principle: Name URL-containing attributes based on their primary purpose. Fixes #278 (#380)
Co-authored-by: Lea Verou <[email protected]>
1 parent c345910 commit eaf5072

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

index.bs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ the functionality you are adding is **not** similar to that of the existing attr
973973
This is an antipattern; one of these groups of attributes should have had a different name.
974974
</div>
975975

976-
<h3 id="avoid-html-parser-blocking"> Do not pause the HTML parser</h3>
976+
<h3 id="avoid-html-parser-blocking">Do not pause the HTML parser</h3>
977977

978978
Ensure that your design does not require HTML parser to pause to handle external resources.
979979

@@ -992,15 +992,29 @@ This is the case of legacy `<script src="…">` elements,
992992
which can inject into the parser using `document.write(…)`.
993993
Due to the performance issues above, new features must not do this.
994994

995-
<h3 id="avoid-render-blocking"> Avoid features that block rendering</h3>
995+
<h3 id="avoid-render-blocking">Avoid features that block rendering</h3>
996996

997997
Features that require resource loading or other operations before rendering the page,
998998
often result in blank page (or the previous page). The result is a poor user experience.
999999

10001000
Consider adding such features only in cases when the overall user experience is improved.
1001-
A canonical example of this is blocking rendering in order to download and process a stylesheet.
1001+
A canonical example of this is blocking rendering in order to download and process a stylesheet.
10021002
The alternative user experience is a flash of unstyled content, which is undesirable.
10031003

1004+
<h3 id="naming-of-url-attributes">Name URL-containing attributes based on their primary purpose</h3><!-- https://github.com/w3ctag/design-principles/issues/278 -->
1005+
1006+
If the element enables the user to navigate to the URL contained in the attribute, call the attribute `href`, like the <{a}> element's <{a/href}> attribute.
1007+
1008+
Note: In hindsight, <{form}>'s <{form/action}> attribute should have been named `href`.
1009+
1010+
If the element causes the resource at the given URL to be loaded, call the attribute `src`, like the <{img}> element's <{img/src}> attribute or the <{script}> element’s <{script/src}> attribute.
1011+
1012+
Note: HTML has a number of legacy inconsistencies that should not be emulated, like the way <{link}>'s <{link/href}> attribute might allow for navigation or for resource loading, depending on the value of the element's <{link/rel}> attribute. <!-- TODO: Add an <object data> example after w3ctag/design-principles#370 has been written. -->
1013+
1014+
If the attribute identifies a URL that is auxilliary to the element's purpose, like <{video}>'s <{video/poster}>, <{q}>'s <{q/cite}>, or <{a}>’s <{a/ping}>, name the attribute after its semantics.
1015+
1016+
Note: remember that attributes containing URLs should be represented in IDL as {{USVString}}; see [[#idl-string-types]].
1017+
10041018
<h2 id="css">Cascading Style Sheets (CSS)</h2>
10051019

10061020
This section details design principles for features which are exposed via CSS.

0 commit comments

Comments
 (0)