w3schools    w3Schools
Search :
   
HOME HTML CSS XML JAVASCRIPT ASP PHP SQL MORE...   References Examples Forum About
ADVERTISEMENTS

XML Certification
Download XML editor
Custom Programming
 
Table of contents
CSS Basic
CSS HOME
CSS Introduction
CSS Syntax
CSS How To
CSS Background
CSS Text
CSS Font
CSS Border
CSS Outline
CSS Margin
CSS Padding
CSS List
CSS Table

CSS Advanced
CSS Dimension
CSS Classification
CSS Positioning
CSS Pseudo-class
CSS Pseudo-element
CSS Image Gallery
CSS Image Opacity
CSS Media Types
CSS Don't
CSS Summary

CSS Examples
CSS Examples

References
CSS2 Reference
CSS2 Print
CSS2 Aural
CSS Units
CSS Colors
CSS Colorvalues
CSS Colornames

CSS Quiz
CSS Quiz
CSS Exam

Selected Reading
Web Statistics
Web Glossary
Web Hosting
Web Quality

Browse Tutorials
 

CSS Background

Previous Next

The CSS background properties define the background effects of an element.


Examples

Set the background color
This example demonstrates how to set the background color for an element.

Set an image as the background
This example demonstrates how to set an image as the background.

How to repeat a background image
This example demonstrates how to repeat a background image.

How to repeat a background image only vertically
This example demonstrates how to repeat a background image only vertically.

How to repeat a background image only horizontally
This example demonstrates how to repeat a background image only horizontally.

How to display a background image only one time
This example demonstrates how to display a background image only one time

How to place the background image
This example demonstrates how to place the image on the page.

How to position a background image using %
This example demonstrates how to position an image on the page using percent.

How to position a background image using pixels
This example demonstrates how to position an image on the page using pixels.

How to set a fixed background image
This example demonstrates how to set a fixed background image. The image will not scroll with the rest of the page.

All the background properties in one declaration
This example demonstrates how to use the shorthand property for setting all of the background properties in one declaration.


CSS Background Properties

The CSS background properties allow you to control the background color of an element, set an image as the background, repeat a background image vertically or horizontally, and position an image on a page.

Browser support: IE: Internet Explorer, F: Firefox, N: Netscape.

W3C: The number in the "W3C" column indicates in which CSS recommendation the property is defined (CSS1 or CSS2).

Property Description Values IE F N W3C
background A shorthand property for setting all background properties in one declaration background-color
background-image
background-repeat background-attachment background-position
4 1 6 1
background-attachment Sets whether a background image is fixed or scrolls with the rest of the page scroll
fixed
4 1 6 1
background-color Sets the background color of an element color-rgb
color-hex
color-name
transparent
4 1 4 1
background-image Sets an image as the background url(URL)
none
4 1 4 1
background-position Sets the starting position of a background image top left
top center
top right
center left
center center
center right
bottom left
bottom center
bottom right
x% y%
xpos ypos
4 1 6 1
background-repeat Sets if/how a background image will be repeated repeat
repeat-x
repeat-y
no-repeat
4 1 4 1


Previous Next