Understanding Color Formats: HEX, RGB & HSL
Why screens mix red, green, and blue light, what HEX shorthand really encodes, and when HSL makes your life easier.
A single CSS property can replace an entire background image. Gradients create depth, energy, and visual hierarchy without adding a single byte of image payload. Combined with a design system that governs your color tokens and spacing scale, gradients become a powerful tool for building consistent, polished interfaces.
CSS supports three gradient functions, each creating a different transition pattern:
| Type | Direction | Best for |
|---|---|---|
| linear-gradient | Along a line | Backgrounds, overlays, dividers |
| radial-gradient | From center outward | Spotlights, glow effects |
| conic-gradient | Around a center point | Pie charts, colour wheels |
Every gradient takes a direction (or shape) and a list of color stops. Each stop defines a color and optionally where it appears along the gradient line (0% to 100%):
/* Linear: angle + color stops */
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
/* Radial: shape + color stops */
background: radial-gradient(circle at center, #f5f7fa 0%, #c3cfe2 100%);
/* Conic: starting angle + color stops */
background: conic-gradient(from 90deg, #ff6b6b, #feca57, #48dbfb, #ff6b6b);
/* Multiple stops with explicit positions */
background: linear-gradient(
to right,
#ee7752 0%,
#e73c7e 25%,
#23a6d5 50%,
#23d5ab 100%
);Prefix any gradient with repeating- to tile it. This is useful for stripe patterns and decorative textures:
/* Diagonal stripes */
background: repeating-linear-gradient(
45deg,
#606dbc,
#606dbc 10px,
#465298 10px,
#465298 20px
);background-clip: text with a gradient to create colorful text fillsborder-image with a gradient for dynamic bordersA design system is a set of reusable rules and components that ensure visual consistency across an entire product. At its core, a design system defines design tokens — the smallest atomic values that make up a visual language:
Without a system, every developer and designer makes ad-hoc decisions: #333 vs #2a2a2a, padding: 14px vs padding: 1rem. These tiny inconsistencies compound into a product that feels subtly wrong. A design system eliminates this by constraining choices to a defined set of tokens.
The most practical approach uses HSL lightness variations. Start with your brand color, keep the hue and saturation fixed, and generate shades by varying lightness:
/* Base brand color: hsl(220, 90%, 50%) */
--color-50: hsl(220, 90%, 97%); /* lightest */
--color-100: hsl(220, 90%, 93%);
--color-200: hsl(220, 90%, 85%);
--color-300: hsl(220, 90%, 72%);
--color-400: hsl(220, 90%, 60%);
--color-500: hsl(220, 90%, 50%); /* base */
--color-600: hsl(220, 90%, 42%);
--color-700: hsl(220, 90%, 34%);
--color-800: hsl(220, 90%, 26%);
--color-900: hsl(220, 90%, 18%); /* darkest */This produces a Tailwind-style 10-step scale where 50 is nearly white and 900 is nearly black. The same hue runs through every shade, ensuring the palette feels cohesive. For production systems, you may also slightly decrease saturation at the extremes to avoid neon highlights and muddy darks.
var(--color-500) in CSS or theme.colors.primary.500 in Tailwind. When the brand color changes, you update one token and the entire product updates.Gradients add visual richness. Design systems add visual discipline. Together, they let you build interfaces that are both beautiful and consistent — at any scale.
Why screens mix red, green, and blue light, what HEX shorthand really encodes, and when HSL makes your life easier.
Lossy vs lossless compression, when transparency matters, and why WebP is replacing both PNG and JPG on the web.
What happens when you drag the quality slider, how DCT transforms photos, and why screenshots compress differently.