Property Values: 1. Styling Backgrounds
Property Values: 1. Styling Backgrounds
Styling Backgrounds
Styling Text
Styling Fonts
Styling Links
Styling Lists
Styling Tables
1. Styling Backgrounds
CSS background properties are used to define the background effects of an element.
background-color
background-image
background-repeat
background-attachment
background-position
Background Color
Example
body {background-color:#b0c4de;}
Property Values
Value Description
color Specifies the background color.
transparent Specifies that the background color should be transparent. This is
default
inherit Specifies that the background color should be inherited from the
parent element
Background Image
Example
body {background-image:url('paper.gif');}
The background of an element is the total size of the element, including padding and
border (but not the margin). By default, a background-image is placed at the top-left
corner of an element, and repeated both vertically and horizontally.
Property Values
Value Description
url('URL' The URL to the image
)
none No background image will be displayed. This is default
inherit Specifies that the background image should be inherited from the parent
element
Background-repeat
Property Values
Value Description
repeat The background image will be repeated both vertically and
horizontally. This is default
repeat-x The background image will be repeated only horizontally
repeat-y The background image will be repeated only vertically
no-repeat The background-image will not be repeated
inherit Specifies that the setting of the background-repeat property should be
inherited from the parent element
Example
body
{
background-image:url('paper.gif');
background-repeat:repeat-y;
}
Background-attachment
The background-attachment property sets whether a background image is fixed or scrolls
with the rest of the page.
Property Values
Value Description
scroll The background image scrolls with the rest of the page. This is default
fixed The background image is fixed
inherit Specifies that the setting of the background-attachment property should be
inherited from the parent element
Example
body
{
background-image:url('smiley.gif');
background-repeat:no-repeat;
background-attachment:fixed;
}