CSS Gradients in HTML5 Code Example

Gradients in CSS3 are valuable addition supported by all modern browsers. No image needed!

.gradientBox {
background: #ffb260; /* older browsers background */
background: -moz-linear-gradient(#ffb260, #ff7f13);
background: -o-linear-gradient(#ffb260, #ff7f13);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#ffb260), to(#ff7f13));/* Older webkit syntax */
background: -webkit-linear-gradient(#ffb260, #ff7f13);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffb260', endColorstr='#ff7f13',GradientType=0 );
}

Note that gradients filter code will not show in IE7 and below. It will show in IE8 and later.

Here’s what it will produce:

Test Gradient

There are more things that can be done, like gradients positions and gradient types, will post about it later here. This tool is excellent to create more complex gradients.

This entry was posted in CSS CheatSheets and tagged , , , . Bookmark the permalink.

2 Responses to CSS Gradients in HTML5 Code Example

  1. html coder says:

    You have five “background” statements? Why? We don’t want to see a bunch of unnecessary BS code … show ONLY the code needed to generate the gradient in a modern browser that supports HTML5/CSS3.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="">