CSS – Linear Gradient with cross browser compatibility.
The Source Code to copy/paste:
.gradient { /* Vertical Gradient Sample */ background-color: #444444; /* Oldest Browsers with no gradient compatibility */ background-image: -webkit-gradient(linear, left top, left bottom, from(#444444), to(#999999)); /* Chrome, Safari 4+ */ background-image: -webkit-linear-gradient(top, #444444, #999999); /* Chrome 10-25, iOS 5+, Safari 5.1+ */ background-image: -moz-linear-gradient(top, #444444, #999999); /* Firefox 3.6-15 */ background-image: -o-linear-gradient(top, #444444, #999999); /* Opera 11.10-12.00 */ background-image: linear-gradient(to bottom, #444444, #999999); /* Chrome 26, Firefox 16+, IE 10+, Opera 12.10+ */ }
If you want IE 6-9 compatibility:
<style type="text/css"> .gradient { /* Horizontal Gradient Sample */ background: #ffffff; /* Old browsers */ /* IE9 SVG, needs conditional override of 'filter' to 'none' */ background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIxMDAlIiB5Mj0iMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMwMDAwMDAiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+); background: -moz-linear-gradient(left, #ffffff 0%, #000000 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, right top, color-stop(0%,#ffffff), color-stop(100%,#000000)); /* Chrome, Safari4+ */ background: -webkit-linear-gradient(left, #ffffff 0%,#000000 100%); /* Chrome10+, Safari5.1+ */ background: -o-linear-gradient(left, #ffffff 0%,#000000 100%); /* Opera 11.10+ */ background: -ms-linear-gradient(left, #ffffff 0%,#000000 100%); /* IE10+ */ background: linear-gradient(left, #ffffff 0%,#000000 100%); /* W3C */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#000000',GradientType=1 ); /* IE6-8 */ } </style> <!--[if gte IE 9]> <style type="text/css"> .gradient { filter: progid:dximagetransform.microsoft.gradient(enabled=false); } </style> <![endif]-->
IE 6-9 compatibility code can creates conflicts with some JavaScript Libraries.