Learn CSS3 to style your web pages

Know what is CSS, its uses and how to add? CSS Style for Text, Paragraphs, Tables, Links and Forms. Background image with CSS, Borders styles in CSS, Set margin and positions in CSS, etc.

CSS3 Background


CSS3 background property is used to add one or more images at a time without HTML code, We can add images as per our requirement.A sample syntax of multi background images is as follows −

CSS3 contains a few new background properties, which allow greater control of the background element.

In this chapter you will learn how to add multiple background images to one element.

You will also learn about the following new CSS3 properties:

  • background-size
  • background-origin
  • background-clip

#multibackground {
background-image: url(/css/images/logo.png), url(/css/images/border.png);
background-position: left top, left top;
background-repeat: no-repeat, repeat;
padding: 75px;
}

the most commonly used values are shown below −

Values Description
background Used to setting all the background image properties in one section
background-clip Used to declare the painting area of the background
background-image Used to specify the background image
background-origin Used to specify position of the background images
background-size Used to specify size of the background images

Following is the example which demonstrate the multi background images

See this example:

<html> <head> <style> #multibackground { background-image: url(/css/images/logo.png), url(/css/images/border.png); background-position: left top, left top; background-repeat: no-repeat, repeat; padding: 75px; } </style> </head> <body> <div id="multibackground"> <h1>www.itchapters.in</h1> </div> </body> </html>

Size of Multi background

Multi background property is accepted to add different sizes for different images.A sample syntax is as shown below −

#multibackground {
background: url(/css/imalges/logo.png) left top no-repeat, url(/css/images/boarder.png) right bottom no-repeat, url(/css/images/css.gif) left top repeat;
background-size: 50px, 130px, auto;
}