You picked the color five minutes ago. It sits in a design file, a screenshot or a client's brand sheet, and now the stylesheet needs it as code. That short trip from sample to CSS is where colors go wrong: a value retyped with one digit off, a rounded number treated as exact, a color pasted in with no note about where it can actually be read.
The Color Picker on Ovatly exists for exactly this handoff. Give it one color, by swatch or by typed HEX, and it shows that color in the three notations CSS work actually uses: HEX, RGB and HSL, each with its own Copy button, plus the color's contrast ratios against black and white. This guide walks the pipeline: sample in, exact CSS out, and the one precision rule that keeps the shipped color identical to the picked one.
Contents
- Quick answer
- One color, three notations
- Copy the notation your stylesheet speaks
- Exact and rounded: the precision rule
- The usage note that travels with the color
- Step by step
- Worked example
- Limitations and honest tradeoffs
- Common mistakes
- FAQs
- Conclusion
Quick answer
Open the Color Picker, pick the color with the swatch or type its HEX value, and read the result panel: the same color spelled as HEX, RGB and HSL. Copy the notation your stylesheet uses with its Copy button rather than retyping it. Record the HEX or RGB value as your source of truth, because those two are always exact. Treat the HSL line as the view you adjust in, not the record you keep, because HSL is rounded to whole numbers and a round trip through it can shift a channel by one unit.
One color, three notations
HEX, RGB and HSL are three spellings of one color. HEX is a compact code, the spelling most CSS is written in. RGB lists the channel amounts directly: how much red, green and blue. HSL describes hue, saturation and lightness, and is the easiest of the three to adjust by eye: keep the hue, then tune saturation and lightness.
The picker shows all three at once because the sample could be in any of them, and the stylesheet might want any of them. You bring one spelling, you leave with all three; the rest of this guide is about which one to trust at each step.
Copy the notation your stylesheet speaks
A stylesheet accepts more than one notation, and a HEX declaration and an rgb() declaration render the identical color when the values match. So the choice is consistency with the file you are working in, not correctness: match the notation the surrounding code already uses.
The real risk here is not the notation, it is transcription. A HEX value has six characters, an RGB value has three numbers, and each one is a chance to type a digit wrong and ship a slightly different color. That is why each notation carries its own Copy button: the value moves from the tool that read it to the file that needs it, nothing retyped in between.
Exact and rounded: the precision rule
Here is the one rule that governs the whole handoff: HEX and RGB are always exact, and HSL is not. The picker rounds HSL values to whole numbers, so converting those rounded values back can differ by one unit in a channel. One unit is invisible on screen.
But invisible is not the same as harmless. A project that records the rounded HSL has quietly replaced the original color with a neighbour, and every future copy spreads the neighbour instead. Two people recording the same picked color, one from the HEX line and one from the HSL line, now hold two records that disagree. The fix is a division of labour: record the HEX or RGB, adjust in HSL, and when an adjustment feels right, read the exact HEX or RGB of the adjusted color and record that. HSL is where you steer; HEX and RGB are where you write things down.
The usage note that travels with the color
A color value on its own is only half the handoff. The other half is knowing where the color can be used, and the picker supplies that too: it shows the color's contrast ratios against black and white.
The worked example below makes this concrete: the blue #2563EB measures 5.17:1 against white, passing the AA minimum of 4.5:1 for normal text, and 4.06:1 against black, failing it. Its usage note reads: text on light backgrounds only. Note it when you copy the value.
Step by step
- Open the Color Picker and pick a color with the swatch, or type a HEX value if you already have one.
- Read the three notations in the result panel.
- Copy the notation your stylesheet needs, using that notation's Copy button, and paste it into your declaration.
- Check the contrast ratios against black and white before you use the color for text.
- Write the HEX or RGB value down as the record, the exact source of truth for this color.
Worked example
Suppose the sample is the blue #2563EB. Typed into the picker, the result panel reads it three ways: rgb(37, 99, 235) and hsl(221, 83%, 53%), alongside the HEX you entered.
If your stylesheet is written in HEX, the declaration is:
.primary-action {
background: #2563EB;
}
In RGB, the same color is:
.primary-action {
background: rgb(37, 99, 235);
}
Both declarations render the identical blue, because both were copied from the same reading rather than converted by hand. The HSL line, hsl(221, 83%, 53%), is the one you would reach for if the blue needed nudging: hold the hue at 221, tune the lightness, and the color moves while staying recognisably the same blue. The contrast panel completes the handoff: this blue goes on light backgrounds, and its record is the HEX, #2563EB.
Limitations and honest tradeoffs
The picker displays three notations, and only three. Its swatch is your operating system's own picker, which may offer extra formats this page does not display. If you pick a color through one of those, bring it back to HEX, RGB or HSL before recording it.
The contrast ratios are given against black and white only, so they give no verdict for a color destined to sit on a third, coloured background. The HSL rounding is a tradeoff, not a bug: whole numbers make it readable at a glance, at the cost of the one-unit round trip.
Common mistakes
- Retyping values instead of copying them. Every retyped digit risks shipping a different color. Use the Copy button.
- Recording the HSL line as the stored value. HSL is rounded to whole numbers, so the record drifts by up to one unit per channel. Store HEX or RGB.
- Adjusting in HSL and pasting the rounded numbers. Adjust by eye in HSL, then read back the exact HEX or RGB of the result and paste that.
- Copying the color and dropping its usage note. A color with no contrast note will eventually be used as text where it fails.
FAQs
Which notation should I paste into my CSS? Any of the three works in a stylesheet. HEX is the compact code most CSS uses, and RGB lists the channel amounts directly. What matters is the copying: use its Copy button in the Color Picker so the value arrives exactly as read.
Why is HSL shown if it is rounded? Because HSL is the easiest notation to adjust by eye: keep the hue, then tune saturation and lightness. The rounding is the price of that readability. Adjust in HSL, then read the HEX or RGB of the result and treat that as the record.
Why did my color change by one unit after I copied the HSL values? HSL values are rounded to whole numbers in the picker, so converting them back can differ by one unit in a channel. HEX and RGB are always exact, so record and reuse one of those instead of the HSL line.
Can I pick a color with the swatch instead of typing a HEX value? Yes. The swatch is your operating system's own picker, and whatever you choose there is read into the same three notations. Note that the OS picker may offer extra formats this page does not display, so bring the final color back to HEX, RGB or HSL before you record it.
Does the picker tell me whether the color works as text? It shows the color's contrast ratios against black and white. The worked blue, #2563EB, measures 5.17:1 against white, which passes the AA minimum of 4.5:1 for normal text, and 4.06:1 against black, which fails it. Check those two numbers before using any picked color for text.
Conclusion
Building a CSS color from a sample is a small pipeline with one rule: copy the notation your stylesheet speaks, and let HEX or RGB be the record, because they are always exact, while HSL stays the view you adjust in. Once the value is in the stylesheet, the next question is how a project keeps its colors straight, which is the subject of How Designers Name and Store Color Values in a Project. For more guides in this series, see the Color and Design Tools guides.