- Background properties
- background-color
- background-image'
- background-repeat
- background-attachment
- background-position
- background-clip
- background-origin
- background-size
- background shorthand
background-color: white;
background-color: #fff;
background-color: #FFFFFF;
background-color: rgb(255,255,255);
background-color: rgb(100%,100%,100%);
background-color: rgba(255,255,255,1);
background-color: rgba(100%,100%,100%, 1);
background-color: hsl(0, 100%, 100%);
background-color: hsla(0, 100%, 100%, 1);
background-color: transparent;
background-color: currentColor;
Confused? See Part 6: Colors & Transparency
none | <url> | inherit
background-image: url(path/aSingleLonelyCat);
background-image: url(brown.gif), url(blue.gif);
none | <url> | <image-list> | <element-reference> | <gradient>
url(singleImage.png) url(multipleImages.gif), url(otherGif.gif) none linear-gradient(top, red, blue) radial-gradient(circle, red, blue) url(data:image/gif;base64,fOulrS123hEAAa517sdfQfda...) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='200'><circle cx='55' cy='190' r='25' fill='#FFF' /></svg>"); element('#someID') image('ico_sprite.jpg#xywh=32,64,16,16') image("try1.svg", 'try2.png' , "try3.gif") image("leftArrow.png" ltr, "rightArrow.png" rtl)
url(singleImage.png) url(multipleImages.gif), url(otherGif.gif) url(SVGImages.svg); url(sprite.png#xywh=40,0,20,20) url(data:image/gif;base64,fOulrS123hEAAa517sdfQfdafsPFRjuy187xxRM221...) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='200'><circle cx='55' cy='190' r='25' fill='#FFF' />^lt;path d='M160 213h-34a82 82 0 0 0 -82 -82v-34a116 116 0 0 1 116 116z' fill='#666'/><path d='M184 213A140 140 0 0 0 44 73 V 38a175 175 0 0 1 175 175z' fill='#666'/></svg>"); SVG Example
Media fragment will not break backwards... hash will be ignored
Allows the use of any element, including <canvas> where images can be used.
background-image: -moz-element('#someID'); background-image: element('#someID')
Define which portion of the image to show:
background-image: -moz-image-rect(url(ico_sprite.jpg), 32, 64, 16, 16); background-image: image('ico_sprite.jpg#xywh=32,64,16,16')
Fallback in case your images doesn't load:
background-image: image("try1.svg", "try2.png", "try3.gif", blue)
Flip the image if the direction is rtl.
background-image: image("arrow.png" rtl)
background-image: url(myGif.gif), url(otherGif.gif); background-image: none; background-image: linear-gradient(top, red, blue); background-image: url(data:image/gif;base64,fOulrShEAAQ...); background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='200'><circle cx='55' cy='190' r='25' fill='#FFF' /></svg>"); background-image: element('#myID'); background-image: image('ico_sprite.jpg#xywh=32,64,16,16'); background-image: image("try1.svg", 'try2.png' , "try3.gif");
Feature | / Browser Firefox | Chrome | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 1 | 1 | 4 | 3.5 | 1 |
Multiple backgrounds | 3.6 | 1 | 9 | yes | 1.3 |
Gradients | 3.6 -moz | 1 -webkit | 10 -ms | 11+ -o | 4 -webkit |
SVG images | 4 | 8 | 9 | 9.5 | 5 |
element() | -moz | ||||
image() | -moz-image-rect() |
background-repeat:
repeat | repeat-x | repeat-y | no-repeat | space | round;
background-repeat: no-repeat;
Should accept 2 values (H & V), but only Opera supports that
Tip: Include background-repeat: no-repeat;
in your reset CSS
background-attachment: fixed | local | scroll
background-attachment: scroll
Filet mignon kielbasa pork chop short ribs short loin shank hamburger. Bresaola hamburger venison shankle pork andouille. Pastrami venison andouille pancetta sausage chicken biltong. Tri-tip jerky short loin tenderloin pork chop. Shoulder frankfurter turkey ribeye, jowl tail leberkase brisket sausage boudin ham hock shankle ground round short loin.
New in CSS3: Positioning relative to any corner
background-position: right 50px bottom 50p;
background-clip: border-box | padding-box | content-box
background-origin: border-box | padding-box | content-box
background-size: auto | contain | cover | <length>
background: img position / size repeat attachment origin clip, img position / size repeat attachment box{1,2} bgcolor;
background: url(topImg.jpg) 0 0 / 30px 30px repeat scroll border-box content-box, url(botImg.jpg) 15px 15px / 30px 30px fixed border-box #609;
border-color: white;
border-color: #fff;
border-color: #FFFFFF;
border-color: rgb(255,255,255);
border-color: rgb(100%,100%,100%);
border-color: rgba(255,255,255,1);
border-color: rgba(100%,100%,100%, 1);
border-color: hsl(0, 100%, 100%);
border-color: hsla(0, 100%, 100%, 1);
border-color: transparent;
border-color: currentColor; /* default */
border-width: (length) | thin | medium | thick | inherit {1,4};
border: width style color;
border-left: width style color;
border-top: 5px dashed rgba(217,68,11, 0.8);
border-radius: 0;
border-radius: 20px;
border-radius: 50%;
border-top-left-radius border-top-right-radius border-bottom-right-radius border-bottom-left-radius
.circle {border-radius: 50%;}
.oval { border-radius: 50%;}
.different { border-radius: 10px 30px;}
.elliptical { border-radius: 10px / 30px;}
.uglier { border-radius: 10px 35px 20px 15px / 30px 35px 5px 5px;}
border-image: source || slice / width / outset || repeat;
border-image-source: none | url() | <image> border-image-slice: <number> | XX% {1,4} && fill border-image-width: <length> | XX% | <number> | 1 | auto {1,4} border-image-outset: <length> | <number> {1,4} border-image-repeat: stretch | repeat | round {1,2}
S = W =
border-image: url(gradient.png) 34 / 34px stretch;