CSS3 Allows Background Controlling

CSS3 Allows Background Controlling is the section 3 of Basics of CSS3.

Background of a web page can be either a color or an image. In this section we are look at the image perspective and the next section we are looking at it in colors perspective.

CSS3 contains several new background properties, which allows greater control of the background element. We are looking at each of them now.

Background Size Property

The background-size property specifies the size of the background image. So now on, what ever the actual image size is, you can define the size of the image it should displayed. With this property we can use the same image in different contexts, without uploading many images with many sizes. This can be either a percentage or a pixel value.

[code language=”css”] div{
background-size: 280px 60px;

This is our original image.



See how we can have the same image with different sizes. We only uploaded this original image only.

You Only Live Once

You Only Live Once

Background Origin Property

Can you remember the box model concept we discussed in our CSS tutorial. Look at the following image to refresh your mind.


CSS Box Model
CSS Box Model

Blue colored area we called it content box.

Green colored area we called it padding box.

Cream colored area we called it border box. 

So we can define, in which box we need to display our background image. In the content box; Most of the time people put there, in the border box or padding box. This is the code snippet to define that.

[code language=”css”] .div1 {
background-origin: border-box;
.div2 {
background-origin: padding-box;
.div3 {
background-origin: content-box;

Multiple Images

This techniques is most useful when having transparent gif, or png format images. What we are going to do now is adding an image on another image. So through the transparent areas, we can see the behind image. Code snippet goes like this.

[code language=”css”] div{
background: url(spiderman.png), url(building.jpg);

We have this image which is transparent. And we used it in the front. So that’s why we we put the url of this image as the first value of background property.

We are going to use this image as the back. So it doesn’t need to be transparent. And that’s why its URL is the second value of the property.

Spiderman Background
You already know the background property and the way to add an image. But with CSS3 you can add multiple images, not only one. See now how it’s looks like. We swear, this image is not Photoshop. Seriously!! It is overlapping of two images.

My Combined Image


Isn’t this really cool. We do not need Photoshop anymore.


In this section we really did insanely awesome stuff using images. CSS3 is kinda cool guy introducing many many unimaginable things on the HTML web pages. Don’t forget we are not finished yet in the subject of backgrounds. Remember what we have promised in the beginning of this section. As we promised the next section is purely for background colors in different perspective.


Explore CSS3 Rainbow Background.

Written by Sandeep Likhar

Sandeep Likhar is from India, where he is a blogger, eBook designer, and founder of LetsDnD. He has 6 years of experience in the industry as a Digital Publishing Expert and eBook Converter, providing services to authors, publishers, and distributors worldwide. He is proficient in converting books into various formats, such as HTML, epub, mobi, word, PDF, including all major online platforms like iTunes, Kobo, Kindle, CreateSpace, B&N, Smashwords, and more.

Comment Below