logo
g Text Version
Auto
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Society & Culture
Sports
Travel & Leisure
TV & Movies

dailyclick
Bored? Games!
Postcards
Astrology
Take a Quiz
Rate My Photo

new
Baptist
Accounting
Current Events
RV
Early Childhood


dailyclick
All times in EST

Full Schedule
g
g HTML Site
Elizabeth Connick
BellaOnline's HTML Editor

g

Placing A Background Image On A Webpage Using Cascading Style Sheets
Guest Author - Diane Cipollo

You can use Cascading Style Sheets to place an image on the background of your webpage. You have the option to tile the background image over the webpage just as you can with HTML. However, you also have several other options when using CSS.

Let's take a look at an example.

Basic CSS Code
<style type="text/css">
<!--
selector {
property_1: value_1;
property_2: value_2;
property_3: value_3
}
-->
</style>

Example
<style type="text/css">
<!--
body {
background-image: url("myimage.jpg");
background-repeat: repeat
}
-->
</style>


Selector
body
To tile a background image across your webpage you would use the body selector in the HTML <body> tag to tell the web browser to apply this style to the background of the entire webpage.

Property
background-image
The background-image is the attribute used to tell the web browser where to find the image you wish to use as your background image. The property name, background-image, is followed by a colon (:).

Value
url("myimage.jpg")
On the right of the colon is the value for the background-image attribute. It will begin with "url" followed by the location (the web address) for the image file that you wish to use. Place this address between quotation marks and parentheses. In our example, the image file is in the same location as the webpage. Therefore, we would only need to use the name of the image file, myimage.jpg, inside the quotation marks and parentheses. However, if the image file is in a different location, you would use that location (web address) as the value of the background-image property just as you would when coding HTML. If you do not wish to use a background image, use the syntax none.
background-image: none

Property
background-repeat
The background-repeat is the attribute that is used to tell the web browser how to tile the image over the webpage. You have several options here. You can tile the image across the webpage both horizontally and vertically (as in HTML). You can also tile the image only horizontally, only vertically or not at all.

Value
repeat
On the right side of the colon is the value for the background-repeat attribute. In our example, we want the image to be tiled both horizontally and vertically over the webpage. Therefore the value is set to repeat. Below are the other values you may wish to use.

background-repeat: repeat-x
This will tile the image across the webpage horizontally.

background-repeat: repeat-y
This will tile the image across the webpage vertically.

background-repeat: no-repeat
The image will appear on the webpage but will not be tiled.





RSS | Previous Features | Site Map


Content copyright © 2008 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact Elizabeth Connick for details.

Digg! g delicious Save to Del.icio.us

g


For FREE email updates, subscribe to the HTML Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor

g features
The Right Way to Start a Paid Website Project

Text Input Options for HTML Forms

Parts of a Website Form

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Driving Amount
Much more
Slightly more
Slightly less
Much less

g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2008 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor