Skip to content

Commit 7318f96

Browse files
committed
[css-values-4][editorial] Add more examples of dashed-ident usage, and some guidance for preprocessors. Closes w3c#5438
1 parent 2c0cf50 commit 7318f96

1 file changed

Lines changed: 47 additions & 1 deletion

File tree

css-values-4/Overview.bs

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,53 @@ Author-defined Identifiers: the <<custom-ident>> type</h3>
591591
For example, [=custom properties=] need to be distinguishable from CSS-defined properties,
592592
as new properties are added to CSS regularly.
593593
To allow this,
594-
[=custom property=] names are required to be <<dashed-ident>>s.
594+
[=custom property=] names are required to be <<dashed-ident>>s,
595+
as in this example:
596+
597+
<pre highlight=css>
598+
.foo {
599+
--fg-color: blue;
600+
}
601+
</pre>
602+
</div>
603+
604+
<div class=example>
605+
<<dashed-ident>>s are also used in the ''@color-profile'' rule,
606+
to separate author-defined color profiles
607+
from pre-defined ones like ''device-cmyk'',
608+
and allow CSS to define more pre-defined (but overridable) profiles in the future
609+
without fear of clashing with author-defined profiles:
610+
611+
<pre highlight=css>
612+
@color-profile --foo { src: url(https://example.com/foo.icc); }
613+
.foo {
614+
color: color(--foo 1 0 .5 / .2);
615+
}
616+
</pre>
617+
</div>
618+
619+
<div class=example>
620+
CSS will use <<dashed-ident>> more in the future,
621+
as more author-controlled syntax is added.
622+
CSS authoring tools,
623+
such as preprocessors that turn custom syntax into standard CSS,
624+
<em>should</em> use <<dashed-ident>> as well,
625+
to avoid clashing with future CSS design.
626+
627+
For example,
628+
if a CSS preprocessor added a new "custom" at-rule,
629+
it <em>shouldn't</em> spell it <css>@custom</css>,
630+
as this would clash with a future official <css>@custom</css> rule added by CSS.
631+
Instead, it should use <css>@--custom</css>,
632+
which is guaranteed to never clash with anything defined by CSS.
633+
634+
Even better, it should use <css>@--library1-custom</css>,
635+
so that if Library2 adds their own "custom" at-rule
636+
(spelled @--library2-custom),
637+
there's no possibility of clash.
638+
Ideally this prefix should be customizable,
639+
if allowed by the tooling,
640+
so authors can manually avoid clashes on their own.
595641
</div>
596642

597643

0 commit comments

Comments
 (0)