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.
In the early days of the web, depth was created with bevels and textures. Then came the era of "Flat Design," which stripped everything down to solid colors. Today, we live in the age of "Modern Flat" or "Material Design," where depth is back — but this time, it's powered by the subtle, mathematical elegance of the CSS box-shadow.
The box-shadow property in CSS is more than just a "glow" effect. It is a multi-parameter function that simulates how light interacts with an object.
/* offset-x | offset-y | blur-radius | spread-radius | color */
box-shadow: 4px 4px 10px 2px rgba(0, 0, 0, 0.2);Real-world shadows aren't just a single grey blur. They are composed of multiple layers of light occlusion. In CSS, you can achieve this by comma-separating multiple shadows on a single element.
box-shadow:
0 1px 1px rgba(0,0,0,0.12),
0 2px 2px rgba(0,0,0,0.12),
0 4px 4px rgba(0,0,0,0.12),
0 8px 8px rgba(0,0,0,0.12);By layering shadows with increasing offsets and blurs, you create a "smooth" shadow that looks significantly more professional than a single, heavy blur.
By adding the inset keyword, the shadow is drawn inside the element's frame. This makes the element appear "sunken" into the page rather than floating above it. This is a core technique for creating form inputs, pressed buttons, or "neumorphic" UI elements.
Google's Material Design popularized the concept of "Elevation." In this system, shadows aren't just decoration; they communicate the distance between two surfaces along the Z-axis.
By using a consistent elevation system, you create a predictable mental model for the user, helping them understand which elements are interactive and which are background.
Shadows define the "vibe" of your interface. Here are three popular styles:
| Style | Characteristics | CSS Vibe |
|---|---|---|
| Retro / Brutalist | Hard edges, high contrast, no blur. | 4px 4px 0px #000 |
| Material / Soft | Subtle, multi-layered, realistic. | 0 10px 15px -3px rgba(0,0,0,0.1) |
| Neumorphic | Light and dark shadows on same-color BG. | 10px 10px 20px #bebebe, -10px -10px 20px #ffffff |
One of the most effective ways to use shadows is the "subtle lift." Instead of a large, obvious shadow, you use a very small offset and a large blur with a low-opacity color.
/* A very subtle lift */
box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);This creates a sense of quality and "premium" feel without the user even consciously noticing that a shadow is present.
Shadows are expensive for the browser to render. When you apply a large blur to a complex shape, the browser has to perform a Gaussian blur calculation on every frame.
To keep your UI snappy:
box-shadow property directly triggers expensive repaints. Instead, animate the opacity of a pseudo-element (::after) that has the shadow.filter: drop-shadow() for non-rectangular shapes (like SVGs or transparent PNGs) as it follows the actual pixels.While they sound similar, box-shadow and the drop-shadow() filter behave differently. Box-shadow follows the "box" of the element, including borders but ignoring transparency. Drop-shadow follows the actual pixels of the content, making it perfect for icons and irregular shapes.
Shadows should never be the *only* way to distinguish an element. Some users with visual impairments or low-quality screens may not be able to see subtle shadows. Always ensure that your UI remains functional and clear even if all shadows were removed.
"A good shadow is like a good movie score: you shouldn't notice it's there, but you'd certainly feel its absence."
Why screens mix red, green, and blue light, what HEX shorthand really encodes, and when HSL makes your life easier.
CSS gradient types and syntax, repeating gradients, what design systems and tokens are, and how to build a color scale from HSL.
How aspect ratios work, where common ratios come from, and why they matter for screens, cameras, and social media.