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 color guides and some associated link updates #33071
Conversation
…first day you learn CSS I didn't remove the link from more basic properties, like color. reordered stuff not fully relevant to the page and safari issue
Co-authored-by: Chris Mills <chrisdavidmills@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful work @estelle!
I've had a good look through your edits, and it is looking pretty much ready to go, IMO.
I've made a few more minor comments for you to look through, but I'm now setting this to approved, so you can get on and merge when done.
|
||
> **Note:** There is no guarantee, though, that `print-color-adjust: exact` will result in your CSS being used exactly as given. | ||
> If the browser provides user preferences to change the output (such as a "don't print backgrounds" checkbox in a print dialog box), that overrides the value of `print-color-adjust`. | ||
> **Note:** A few now obsolete HTML attributes accepted colors as values, such as `bgcolor` and `vlink`. These attribute only accepted {{cssxref("named-color")}} and three or six digit {{cssxref("hex-color")}} values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> **Note:** A few now obsolete HTML attributes accepted colors as values, such as `bgcolor` and `vlink`. These attribute only accepted {{cssxref("named-color")}} and three or six digit {{cssxref("hex-color")}} values. | |
> **Note:** A few now-obsolete HTML attributes accepted colors as values, such as `bgcolor` and `vlink`. These attributes only accepted {{cssxref("named-color")}} and three- or six-digit {{cssxref("hex-color")}} values. |
|
||
The use of color is a fundamental form of human expression. Children experiment with color before they even have the manual dexterity to draw. Maybe that's why color is one of the first things people often want to experiment with when learning to develop websites. With [CSS](/en-US/docs/Web/CSS), there are lots of ways to add color to your [HTML](/en-US/docs/Web/HTML) [elements](/en-US/docs/Web/HTML/Element) to create just the look you want. | ||
> **Note:** It is important to [use colors wisely](/en-US/docs/Web/CSS/CSS_colors/Using_color_wisely). Always select appropriate colors, ensure there is enough contrast between text and the background to ensure legibility, and always keep the needs of people with differing visual capabilities in mind. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> **Note:** It is important to [use colors wisely](/en-US/docs/Web/CSS/CSS_colors/Using_color_wisely). Always select appropriate colors, ensure there is enough contrast between text and the background to ensure legibility, and always keep the needs of people with differing visual capabilities in mind. | |
> **Note:** It is important to [use colors wisely](/en-US/docs/Web/CSS/CSS_colors/Using_color_wisely). Always select appropriate colors, ensure the contrast between text and backgrounds is sufficient to ensure legibility, and always keep the needs of people with differing visual capabilities in mind. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
went with:
ensuring the contrast between text and the background is sufficient
|
||
## See also | ||
|
||
- [`<color>`](/en-US/docs/Web/CSS/color_value) data type | ||
- [CSS color values](/en-US/docs/Web/CSS/CSS_colors/Color_values) guide | ||
- [Using colors wisely](/en-US/docs/Web/CSS/CSS_colors/Using_color_wisely) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- [Using colors wisely](/en-US/docs/Web/CSS/CSS_colors/Using_color_wisely) | |
- [Using color wisely](/en-US/docs/Web/CSS/CSS_colors/Using_color_wisely) |
@@ -6,31 +6,27 @@ page-type: guide | |||
|
|||
{{CSSRef}} | |||
|
|||
This tool makes it easy to create, adjust, and experiment with custom colors for the web. It also makes it easy to convert between various [color formats](/en-US/docs/Web/CSS/color_value) supported by [CSS](/en-US/docs/Web/CSS), including: HEXA colors, RGB (Red/Green/Blue) and HSL (Hue/Saturation/Lightness). Control over the alpha channel is also supported. | |||
This tool lets you pick a color in the sRGB {{glossary("color space")}} and converts it between various CSS [color formats](/en-US/docs/Web/CSS/color_value), helping you understand the syntax of sRGB color notations, including: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tool lets you pick a color in the sRGB {{glossary("color space")}} and converts it between various CSS [color formats](/en-US/docs/Web/CSS/color_value), helping you understand the syntax of sRGB color notations, including: | |
This tool lets you pick a color in the sRGB {{glossary("color space")}} and converts it between various CSS [color formats](/en-US/docs/Web/CSS/color_value), helping you understand the syntax of the following sRGB color notations: |
|
||
Color keywords include standard primary and secondary colors (such as `red`, `blue`, or `orange`), shades of gray (from `black` to `white`, including colors like `darkgray` and `lightgrey`), and a variety of other blended colors, including `lightseagreen`, `cornflowerblue`, and `rebeccapurple`. Named colors use the [RGB](/en-US/docs/Glossary/RGB) model and are associated with the sRGB (`srgb`) color space. | ||
|
||
There are over 160 named colors. There are named colors of special interest: [`transparent`](/en-US/docs/Web/CSS/named-color#transparent) sets a transparent color value, while [`currentcolor`](/en-US/docs/Web/CSS/color_value#currentcolor_keyword) sets the current value of the CSS {{cssxref("color")}} property. There are also named {{cssxref("system-colors")}}, such as `accentcolortext` and `buttonface`, that reflect the default color choices made by the user, the browser, or the operating system. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are over 160 named colors. There are named colors of special interest: [`transparent`](/en-US/docs/Web/CSS/named-color#transparent) sets a transparent color value, while [`currentcolor`](/en-US/docs/Web/CSS/color_value#currentcolor_keyword) sets the current value of the CSS {{cssxref("color")}} property. There are also named {{cssxref("system-colors")}}, such as `accentcolortext` and `buttonface`, that reflect the default color choices made by the user, the browser, or the operating system. | |
There are over 160 named colors. There are named colors of special interest: [`transparent`](/en-US/docs/Web/CSS/named-color#transparent) sets a transparent color value, while [`currentcolor`](/en-US/docs/Web/CSS/color_value#currentcolor_keyword) sets the current value of the CSS {{cssxref("color")}} property. There are also named {{cssxref("system-color")}}s, such as `accentcolortext` and `buttonface`, that reflect the default color choices made by the user, the browser, or the operating system. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(or just turn it into a regular link, either way the link would be fixed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are also named {{cssxref("system-color")}} colors, such as ...
<td style="background-color: hsl(0.15turn 90% 50%);"> </td> | ||
</tr> | ||
<tr> | ||
<td><code>hsl(270deg 90% 50%)</code></td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<td><code>hsl(270deg 90% 50%)</code></td> | |
<td><code>hsl(270deg 90% 50% / 50%)</code></td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!
|
||
Similar to `lch()` and `oklch()`, the `lightness` is either a {{cssxref("percentage")}} or for `lab()` a number between `0` and `100` and for `oklab()` a number between `0` and `1`, with `0` or `0%` being the complete lack of lightness, which is black. | ||
|
||
The `a` value is `<number>` between `-125` and `125` for `lab()` or `-0.4` and `0.4` for `oklab()`, a `<percentage>` between `-100%` and `100%`, or the keyword `none` (equivalent to `0%` in this case). This value specifies the color's distance along the a-axis in the color space, which defines how green (moving towards -100%) or red (moving towards +100%) the color is. Note that these values are signed (allowing both positive and negative values) and theoretically unbounded, meaning that you can set values outside the ±125 or ±0.4 (±100%) limits. In practice, values cannot exceed ±160 or ±0.5, respectively. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOL, I'll redo that one in a different comment. I think I forgot to add it ;-)
- A {{cssxref("percentage")}}, with `0%` being completely black and `100%` being completely white. | ||
- A number between `0` and `100` for `lab()` and `0` and `1` for `oklab()`, where `0` is completely black and`1`/`100` is completely white. | ||
|
||
The `a` value is `<number>` between `-125` and `125` for `lab()` or `-0.4` and `0.4` for `oklab()`, a `<percentage>` between `-100%` and `100%`, or the keyword `none` (equivalent to `0%` in this case). This value specifies the color's distance along the a-axis in the color space, which defines how green (moving towards -100%) or red (moving towards +100%) the color is. Note that these values are signed (allowing both positive and negative values) and theoretically unbounded, meaning that you can set values outside the ±125 or ±0.4 (±100%) limits. In practice, values cannot exceed ±160 or ±0.5, respectively. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The `a` value is `<number>` between `-125` and `125` for `lab()` or `-0.4` and `0.4` for `oklab()`, a `<percentage>` between `-100%` and `100%`, or the keyword `none` (equivalent to `0%` in this case). This value specifies the color's distance along the a-axis in the color space, which defines how green (moving towards -100%) or red (moving towards +100%) the color is. Note that these values are signed (allowing both positive and negative values) and theoretically unbounded, meaning that you can set values outside the ±125 or ±0.4 (±100%) limits. In practice, values cannot exceed ±160 or ±0.5, respectively. | |
The `a` value is a `<number>` between `-125` and `125` for `lab()` or `-0.4` and `0.4` for `oklab()`, a `<percentage>` between `-100%` and `100%`, or the keyword `none` (equivalent to `0%` in this case). This value specifies the color's distance along the a-axis in the color space, which defines how green (moving towards -100%) or red (moving towards +100%) the color is. | |
Note that these values are signed (allowing both positive and negative values) and theoretically unbounded, meaning that you can set values outside the ±125 or ±0.4 (±100%) limits. In practice, values cannot exceed ±160 or ±0.5, respectively. |
} | ||
``` | ||
|
||
In addition, as the older sRGB color notations discussed above - `hsl()`, `hwb()`, and `rgb()` - do not express the full spectrum of visible colors and the `color()` function supports a much wider color gamut, when using these functions to define relative colors (discussed next), the output color returned by querying {{domxref("HTMLElement.style")}} property or the {{domxref("CSSStyleDeclaration.getPropertyValue()")}} method will be a `color(srgb ...)` value. To see an example of converting these color functions to `color()` in the `srgb` color space, check out our [color picker tool](/en-US/docs/Web/CSS/CSS_colors/Color_picker_tool). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition, as the older sRGB color notations discussed above - `hsl()`, `hwb()`, and `rgb()` - do not express the full spectrum of visible colors and the `color()` function supports a much wider color gamut, when using these functions to define relative colors (discussed next), the output color returned by querying {{domxref("HTMLElement.style")}} property or the {{domxref("CSSStyleDeclaration.getPropertyValue()")}} method will be a `color(srgb ...)` value. To see an example of converting these color functions to `color()` in the `srgb` color space, check out our [color picker tool](/en-US/docs/Web/CSS/CSS_colors/Color_picker_tool). | |
The older sRGB color notations discussed above — `hsl()`, `hwb()`, and `rgb()`— do not express the full spectrum of visible colors, while the `color()` function supports a much wider color gamut. As a result, when using the older functions types to define relative colors (discussed next), the output color returned by querying {{domxref("HTMLElement.style")}} property or the {{domxref("CSSStyleDeclaration.getPropertyValue()")}} method will be a `color(srgb ...)` value. To see an example of converting these color functions to `color()` in the `srgb` color space, check out our [color picker tool](/en-US/docs/Web/CSS/CSS_colors/Color_picker_tool). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think you should remove this paragraph from here, put it in place of the related paragraph in the next section, and remove the "(discussed next)" bit. It seems weird that the detail is here and not in the relative colors section.
Yes, this section uses color()
, but this detail is not essential for an understanding of the example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to:
Understanding
color()
is important when it comes to relative colors, discussed next. The older sRGB color notations discussed above —hsl()
,hwb()
, andrgb()
— do not express the full spectrum of visible colors, while thecolor()
function supports a much wider color gamut. As a result, when using the older functions types to define relative colors, the output color returned by querying {{domxref("HTMLElement.style")}} property or the {{domxref("CSSStyleDeclaration.getPropertyValue()")}} method will be acolor(srgb ...)
value.
To see an example of converting the
hsl()
,hwb()
, andrgb()
color functions tocolor()
in thesrgb
color space, check out our color picker tool.
to make it more relevant here (i want to add it to color() instead of relative because i want to express why learning color is actually important.
|
||
It's important to [understand color and luminance](/en-US/docs/Web/Accessibility/Understanding_Colors_and_Luminance) and to always consider [color blindness](https://medlineplus.gov/colorblindness.html) and [vestibular disorders](/en-US/docs/Web/Accessibility/Seizure_disorders). There are several kinds; the most common is red-green color blindness, which causes people to be unable to differentiate between the colors red and green. There are others, too, ranging from an inability to tell the difference between certain colors to the total inability to see color at all. There are even color and animation combinations that can lead your photosensitive users to experience [seizures](/en-US/docs/Web/Accessibility/Seizure_disorders#colors). | ||
|
||
While higher [color contrast](https://digital.gov/guides/accessibility-for-teams/visual-design/#color-and-contrast) is often a good thing when it comes to accessibility, when animating, especially rapidly, [reducing color contrast](/en-US/docs/Web/Accessibility/Seizure_disorders#reduce_contrast) on animating elements reduces seizure risk. If you include animations, use the [`prefers-reduced-motion`](/en-US/docs/Web/CSS/@media/prefers-reduced-motion) feature of the {{cssxref("@media")}} query to reduce animations for users who have selected that preference. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While higher [color contrast](https://digital.gov/guides/accessibility-for-teams/visual-design/#color-and-contrast) is often a good thing when it comes to accessibility, when animating, especially rapidly, [reducing color contrast](/en-US/docs/Web/Accessibility/Seizure_disorders#reduce_contrast) on animating elements reduces seizure risk. If you include animations, use the [`prefers-reduced-motion`](/en-US/docs/Web/CSS/@media/prefers-reduced-motion) feature of the {{cssxref("@media")}} query to reduce animations for users who have selected that preference. | |
While higher [color contrast](https://digital.gov/guides/accessibility-for-teams/visual-design/#color-and-contrast) is often a good thing when it comes to accessibility, when animating, especially rapidly, [reducing color contrast](/en-US/docs/Web/Accessibility/Seizure_disorders#reduce_contrast) on animating elements reduces seizure risk. If you include animations, use the [`prefers-reduced-motion`](/en-US/docs/Web/CSS/@media/prefers-reduced-motion) {{cssxref("@media")}} query feature to reduce animations for users who have selected that preference. |
Four guides on CSS colors:
<color>
values. It's a guide to using CSS to apply color to a variety of types of content, including all CSS properties that accept<color>
as a value.color()
function will show in the tool when add color() function to color tool css-examples#176 is merged. it's not there at the moment).(* these are the links to the previews of the main pages that have really changed / are new. Also, see the module landing page. All other files have minor edits, mostly "applying color" link removals. Hopefully, this section may be helpful once those link pages have passed muster as we go through rounds of reviews ;) )
This PR only includes updated links to "applying color", removing the link from CSS properties in which our readers, if they are using those properties, already know how to apply CSS to elements.
There will be a separate PR to add links to the three other guides. This PR is already big enough.
Fixes openwebdocs/project#194
Sidebar additions: mdn/yari#10945
Tool update: mdn/css-examples#176