Coding task · HTML and CSS course · Module 9: Modern CSS

Animated Gradients with @property

The @property rule registers a typed Custom Property that the browser can animate! @property --color { syntax: "<color>"; inherits: false; initial-value: gold; } - now a gradient with var(--color) can smoothly change colors like the magical formulas of pharaohs.

Task

Register @property --color-a and --color-b with syntax "<color>". Create a gradient background: linear-gradient(135deg, var(--color-a), var(--color-b)) and add transitions on --color-a and --color-b. Change the colors on :hover - you'll see a smooth gradient animation!