Skip to content

Commit 2bdf28b

Browse files
committed
[css-color] Fix rgb() grammar to correctly state that you have to use all numbers or all %s. Since grammar is getting complex, move legacy syntaxes lower down, and make hsl() match.
1 parent 07cde66 commit 2bdf28b

1 file changed

Lines changed: 25 additions & 23 deletions

File tree

css-color/Overview.bs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,12 @@ The RGB functions: ''rgb()'' and ''rgba()''</h3>
171171
Its syntax is:
172172

173173
<pre class='prod'>
174-
<dfn>rgb()</dfn> = rgb( <<rgb-component>>{3} [ / <<alpha-value>> ]? ) |
175-
rgb( <<rgb-component>>#{3} , <<alpha-value>>? )
176-
<dfn>rgba()</dfn> = rgba( <<rgb-component>>{3} [ / <<alpha-value>> ]? ) |
177-
rgba( <<rgb-component>>#{3} , <<alpha-value>>? )
178-
<dfn>&lt;rgb-component></dfn> = <<number>> | <<percentage>>
174+
<dfn>rgb()</dfn> = rgb( <<percentage>>{3} [ / <<alpha-value>> ]? ) |
175+
rgb( <<number>>{3} [ / <<alpha-value>> ]? )
179176
<dfn>&lt;alpha-value></dfn> = <<number>> | <<percentage>>
180177
</pre>
181178

182-
The three <<rgb-component>>s specify the red, green, and blue channels of the color, respectively.
179+
The first three arguments specify the red, green, and blue channels of the color, respectively.
183180
''0%'' represents the minimum value for that color channel in the sRGB gamut,
184181
and ''100%'' represents the maximum value.
185182
A <<number>> is equivalent to a <<percentage>>,
@@ -204,14 +201,18 @@ The RGB functions: ''rgb()'' and ''rgba()''</h3>
204201
Values outside these ranges are not invalid,
205202
but are clamped to the ranges defined here at computed-value time.
206203

207-
Note: For legacy reasons,
208-
the ''rgb()'' function and ''rgba()'' functions both exist,
209-
but are aliases of each other.
204+
For legacy reasons,
205+
''rgb()'' also supports an alternate syntax
206+
that separates all of its arguments with commas:
207+
208+
<pre class='prod'>
209+
rgb() = rgb( <<percentage>>#{3} , <<alpha-value>>? ) |
210+
rgb( <<number>>#{3} , <<alpha-value>>? )
211+
</pre>
212+
210213
Also for legacy reasons,
211-
both functions have an alternate syntax separating their arguments with commas,
212-
rather than the standard color-function format
213-
of space-separated arguments
214-
and an optional slash-separated opacity.
214+
an <dfn>rgba()</dfn> function also exists,
215+
with an identical grammar and behavior to ''rgb()''.
215216

216217
<h3 id='hex-notation'>
217218
The RGB hexadecimal notations: ''#RRGGBB''</h3>
@@ -713,10 +714,7 @@ HSL Colors: ''hsl()'' and ''hsla()'' functions</h2>
713714
The syntax of the ''hsl()'' function is:
714715

715716
<pre class='prod'>
716-
<dfn>hsl()</dfn> = hsl( <<hue>> <<percentage>> <<percentage>> [ / <<alpha-value>> ]? ) |
717-
hsl( <<hue>>, <<percentage>>, <<percentage>>, <<alpha-value>>? )
718-
<dfn>hsla()</dfn> = hsla( <<hue>> <<percentage>> <<percentage>> [ / <<alpha-value>> ]? ) |
719-
hsla( <<hue>>, <<percentage>>, <<percentage>>, <<alpha-value>>? )
717+
<dfn>hsl()</dfn> = hsl( <<hue>> <<percentage>> <<percentage>> [ / <<alpha-value>> ]? )
720718
<dfn>&lt;hue></dfn> = <<number>> | <<angle>>
721719
</pre>
722720

@@ -770,13 +768,17 @@ HSL Colors: ''hsl()'' and ''hsla()'' functions</h2>
770768
</pre>
771769
</div>
772770

773-
Note: For legacy reasons, the ''hsl()'' function and ''hsla()'' functions both exist,
774-
but are aliases of each other.
771+
For legacy reasons,
772+
''hsl()'' also supports an alternate syntax
773+
that separates all of its arguments with commas:
774+
775+
<pre class='prod'>
776+
hsl() = hsl( <<hue>>, <<percentage>>, <<percentage>>, <<alpha-value>>? )
777+
</pre>
778+
775779
Also for legacy reasons,
776-
both functions have an alternate syntax separating their arguments with commas,
777-
rather than the standard color-function format
778-
of space-separated arguments
779-
and an optional slash-separated opacity.
780+
an <dfn>hsla()</dfn> function also exists,
781+
with an identical grammar and behavior to ''hsl()''.
780782

781783

782784
<h3 id='hsl-to-rgb'>

0 commit comments

Comments
 (0)