How the browser draws a linear gradient
A linear gradient is painted along an imaginary gradient line that passes through the centre of the box at the angle you choose. 0deg points up, 90deg points right and 180deg points down, so 90deg is the same as to right. Colours change along that line and stay constant at right angles to it.
The line is sized so the first and last colours land exactly in the corners. For an angle a on a box W wide and H tall, its length is |W sin a| + |H cos a|. On a 300px by 200px box at 45deg that is 300 x 0.7071 + 200 x 0.7071, about 353.6px. This is why the same gradient looks steeper on a wide banner than on a square card.
Without explicit stop positions, colours are spread evenly: two colours at 0% and 100%, three colours at 0%, 50% and 100%. Add positions after any colour, for example #4f46e5 0%, #8b5cf6 30%, #ec4899 100%, to bias the blend. Radial gradients spread outward from the centre, and conic gradients sweep colours around the centre like a pie chart, starting from the angle given after from.
Worked example: reading a box-shadow
The default output, box-shadow: 0px 10px 25px -5px with a colour at 40% opacity, works like this on a 200px by 100px card. Spread first shrinks the shadow by 5px on every side to 190px by 90px. The 10px Y offset then moves it down. The blur radius softens the edge, fading over a band that extends roughly 25px either side of the shadow's edge.
The result: the shadow's bottom edge sits 5px below the card (10px offset minus 5px spread) and fades out about 25px beyond that. At the top, the shadow edge is 15px inside the card, and the blur reaches up to about 10px above it, so only a faint trace shows. A negative spread is what keeps a soft shadow from bleeding out at the sides, which makes a card look lifted rather than smudged.
How corner radii are scaled when they are too large
border-radius values are not applied blindly. If the two radii along one side add up to more than that side's length, the browser scales every radius on the element down by the same factor until they fit.
For example, set all four corners to 100px on a 200px by 100px button. Along the top edge, 100 + 100 = 200 fits the 200px width exactly. Along the left edge, 100 + 100 = 200 is twice the 100px height, so the factor is 0.5 and every corner becomes 50px. The result is a perfect pill shape. This is why designers often write border-radius: 9999px for pills: the browser clamps it to the largest radius that fits.
Practical tips for real interfaces
Shadows look more natural when they borrow the hue of the element or background rather than pure black at high opacity. Layering two shadows, a tight one for contact and a wide, faint one for ambient light, gives more convincing depth than one heavy shadow.
Animating box-shadow forces a repaint every frame. For hover elevation, a common technique is to put the larger shadow on a pseudo-element and transition its opacity instead, which the browser can handle more cheaply.
Gradients behind text need the same contrast checks as solid colours, measured at the lightest point under the text. Two saturated hues mixed in sRGB can also pass through a muddy grey in the middle; adding a third stop in between, as this tool allows, often fixes that.
Gradient & Shadow Studio: frequently asked questions
What is the difference between blur radius and spread radius?
Blur controls how soft the shadow's edge is, while spread grows or shrinks the shadow's size before the blur is applied. A positive spread makes the shadow larger than the element, and a negative spread tucks it underneath. Neither value moves the shadow; that is the job of the X and Y offsets.
Can an element have more than one box-shadow?
Yes. Separate shadows with commas in one box-shadow declaration, and the first one listed is drawn on top. Combining inset and outer shadows on the same element is also allowed.
Why does my gradient show visible bands?
Banding happens when a gradient spans a large area between two close colours, because there are not enough distinct colour values to fill the distance smoothly. Increasing the colour difference, adding a middle stop or overlaying a very subtle noise texture all reduce it.
What does a conic gradient's from angle do?
It sets where the colour sweep begins. With from 0deg the first colour starts at the top and the sweep runs clockwise; from 90deg starts it at the right. Conic gradients are useful for pie charts, colour wheels and angled sheen effects.
How do I put a shadow on only one side of an element?
Use a negative spread equal to the blur radius so the shadow does not show at the sides, then offset it toward the side you want. For example, box-shadow: 0 8px 6px -6px rgba(0, 0, 0, 0.3) gives a shadow along the bottom edge only.