How to make a pure CSS div with a gradient background?

AngryHacker picture AngryHacker · Aug 17, 2010 · Viewed 61.8k times · Source

Let's say the height of the div is 34px and the width is 480px. The div should look like this:

alt text

and I don't want it to actually use an image, just CSS. Is it possible?

Answer

user113292 picture user113292 · Aug 17, 2010

It is with CSS3. There's even a handy gradient generator which takes the guesswork out of it. Of course, this is completely unsupported in IE8 and under.


Edit

For the sake of completeness, as sluukkonen mentioned, IE does support gradients in CSS using the filter filter:progid:DXImageTransform.Microsoft.Gradient.