CSS Background Color Generator

Generate a solid CSS background-color declaration from RGB or HSL values, or paste an existing CSS color to inspect its normalized HEX, RGB, and HSL forms.

Last updated: August 2026 | By Workshelve Team

Generated CSS and normalized color values will appear here.

What CSS background-color Controls

The CSS background-color property paints a single solid color behind an element's content and padding. It is the right property for cards, buttons, panels, page backgrounds, and fallback colors behind images.

This generator focuses on solid colors. It accepts numeric RGB channels, HSL values, and alpha opacity, then returns a paste-ready declaration plus equivalent HEX, RGB, and HSL notations for design handoff.

Use the CSS to Values mode when you inherit a color from a stylesheet and need to understand its channels. The parser normalizes HEX shorthand, RGB percentages, alpha values, and modern HSL slash-alpha syntax.

How the Color Values Are Calculated

1. RGB input accepts finite numeric channels from 0 through 255, including decimals allowed by CSS Color.
2. HSL hue accepts decimals and valid negative angles, then wraps onto the 0-360 degree color wheel.
3. Saturation and lightness are percentages from 0 through 100; alpha is a decimal opacity from 0 through 1.
4. Output preserves RGB decimals to six places when needed, reports HSL to one decimal, alpha to three decimals, and rounds to 8-bit channels only when producing six-digit HEX.
rgb(14, 165, 233)
background-color: #0EA5E9;
rgba(15, 23, 42, 0.92)
background-color: rgba(15, 23, 42, 0.92);
hsl(160 84% 39% / 0.85)
background-color: rgba(15.912, 183.078, 127.356, 0.85);
#0f172a
RGB: rgb(15, 23, 42)

Worked Example: Transparent Panel Background

Build a dark translucent panel background from RGB(15, 23, 42) with alpha 0.92:

Channels
R 15, G 23, B 42, A 0.92
CSS
background-color: rgba(15, 23, 42, 0.92);
Note

Alpha 0.92 leaves a small amount of underlying page color visible, which can soften dark panels while keeping text contrast close to the opaque color.

CSS Background Color FAQ

Is background-color the same as background?

No. background-color sets only the solid color layer. The shorthand background property can also reset images, repeat behavior, size, position, and other background settings.

Can this generate gradients?

No. Gradients are images in CSS and belong in background or background-image. This tool is intentionally limited to solid background colors.

Can I enter decimal RGB channels?

Yes. CSS rgb() channels can be numeric values, including decimals. This tool accepts values from 0 to 255 and preserves useful decimal precision; six-digit HEX is necessarily rounded to 8-bit channel values.

Are negative values supported?

Negative RGB, saturation, lightness, and alpha values are invalid. Negative HSL hue is accepted because CSS angles can wrap around the color wheel.

Why does HEX disappear when alpha is below 1?

Six-digit HEX cannot represent transparency. The main declaration uses rgba() when alpha is below 1, while the HEX line still shows the opaque base color.

Does this parse named colors like red or transparent?

No. It parses numeric HEX, RGB(A), and HSL(A) values so the output can show exact channel math without browser color-name lookup.

Can I paste a full declaration?

Yes. Paste background-color: #0f172a; or just #0f172a. The parser extracts the color value and normalizes it.

Does a transparent background affect text contrast?

Yes. Semi-transparent backgrounds blend with whatever sits behind them, so final contrast depends on the actual page underneath.

Related Tools