CSS gradients are images generated from color transitions. A linear-gradient() moves along a line; a radial-gradient() spreads from a center. Both accept color stops, so you can control not just the colors but where each transition begins and ends.
Start with a simple linear gradient
.hero {
background-image: linear-gradient(
135deg,
#3f2b96 0%,
#7357e8 55%,
#a894f1 100%
);
}
The angle changes the direction. Explicit stop positions make the example easier to tune and maintain. Add another stop only when the design needs a distinct transition; too many close stops can create bands or an uneven blend.
Check text over the full background
Text placed on a gradient may pass contrast over one part and fail over another. Test the lightest and darkest areas behind the text. If the contrast changes too much, place text on a solid surface or add a restrained overlay behind it.
Use a preview as a starting point
A visual generator can help you find a direction faster than repeatedly editing values. Copy the CSS, then inspect it at the real element size and against neighboring surfaces. For an accessible interface, the gradient is decoration; it should not carry essential meaning by itself.
Try the CSS gradient generator and check text pairs with the WCAG contrast checker. See the linear-gradient reference for the full syntax.