A look into the Backgroung Properties of CSS

17. March 2010 09:34

A further look into CSS

CSS styling consists of a set of properties that can be applied to the HTML elements that support them. Today we will take a look at the background properties.

 

background-color—Applies a background color to the HTML element whose tags it is inside of. This is good way to give color particular parts of the page. If you want the “h1” header to have a blue background and the “h2” to have a green background, you can easily make that happen.

h1

{

 background-color: blue;

}

h2

{

 background-color: green;

}

 

As with HTML, colors can also be assigned hex values and RGB values.

The rest of the background properties revolve around background images and their manipulation.

 

background-image—Used to set an image as a background for that element. The code will look like: background-image:url(‘thepicture.jpg’);

Options: url(), none, inherit

background-attachement—Determines whether the picture is fixed or moves with the scrolling of the webpage.

  Options: scroll, fixed, inherit

background-poisition—Used to set the location of the image on the page. Images can be set at general locations as the center of the page or specific X and Y coordinates.

Options: top left, top center, top right, center left, center center, center right, bottom left, bottom center, bottom right, x% y%, xpos ypos, inherit

background-repeat—Set how the background image will repeat itself or not repeat itself. You can also set images to repeat on only one axis.

Options: repeat, repeat-x, repeat-y, no-repeat, inherit

To save time one can also combine all of the attributes into one CSS tag called “background”. This can be good to save space on coding. To use this abbreviated property, attributes must be used in the order as they are numbered on this page.

i.e.  color, image, repeat, attachment, position

h1

{

 background:red url(‘image.jpg’) repeat-y center left

}





Comments

4/28/2010 1:02:12 AM #

Rapidshare

I\'m happy I found this blog, I couldnt discover any info on this subject matter prior to. I also run a site and if you want to ever serious in a little bit of guest writing for me if possible feel free to let me know, i\'m always look for people to check out my site. Please stop by and leave a comment sometime!

Rapidshare United States |

5/8/2010 6:50:18 PM #

Mariana

Amazing! Not clear for me, how often you updating your site?

Mariana United States |

5/8/2010 8:46:48 PM #

svan high chair cushion

this will be a handy reference for me, thanks much

svan high chair cushion United States |

5/20/2010 1:59:21 AM #

Wahdo

Amazing! Not clear for me, how often you updating your site?

Wahdo United States |

6/9/2010 2:09:40 PM #

Custom Logo Design

That's nice thing you shared. but it seems there is some thing missing.

Custom Logo Design United Kingdom |

7/15/2010 5:59:45 AM #

Local Internet Marketing

CSS is a very powerful programming language. I try to learn it. I hope I will learn it successfully. Thanks.

Local Internet Marketing United States |

8/20/2010 12:39:31 PM #

Tampa Web Design

Valuable info and wonderful design you got right here! I don't know what to say. This blog is fantastic. That is not really a really huge statement, but its all I could come up with after reading this. You know so much about this subject. So much so that you made me want to learn more about it.

Tampa Web Design United States |



About the author

 The creators of the Web Design Blog have been creating web designs for over 12 years

Page List