HTML Cookbook Basic HTML Course

It's Easy!

CSS Step By Step


Alternate Version

CSS Background Images

There is one final body tag attribute we haven't replaced yet, the background attribute.

HTML body tag: <body background="URL">

In CSS,
background="URL"
is replaced by
background-image: url(image.jpg).

url tells a browser that it needs to load a URL. image.jpg would be the URL of the image. The URL may be relative or absolute.

Let's see this in a stylesheet.

body { background-image: url(marble10.jpg) }

Here is my image: http://www.htmlcookbook.com/images/marble10.jpg
marble10.jpg

I made a sample page showing this background image in the body element.

I like this effect so I made a class for it:
.marble { background-image: url(marble.gif)}

CSS does not limit me to using the background-image for a page. Now that I have a class for my background-image, I can use it in just about any element, so I made sample pages using the class in a div, a paragragh and a span.

Assignment

Make a sample page using background-image. You may put it anywhere on your page. Post your page.

Happy coding!
Gnubee

Links
Tips
Tools
References
Rules
HTML Help Gnubee - Newsgroup
HTML Course Contents (Home)

Valid XHTML 1.0!

Valid CSS!