Post by: Eric Li
HTML tutorial
7Background
Let's say you want to insert a background image to your web page, how to do that?Here is the page for the above code.
<html>
<head>
<title>Background image</title>
<style>
body { background-image:url(/np/brain.png); background-repeat: repeat-y repeat-x}
div {background-color:9EB4FF}
</style>
</head>
<body>
<div>Bla bla bla...</div>
</body>
</html>
The "background-image:url(image url here)" after body in between the <style>, </style> tags and enclosed by the two curly brackets { }, attributes the image in the given url to the body and is known as its background.
The "background-repeat: repeat-y repeat-x" makes the given image repeat to the vertical (repeat-y) and to the horizontal (repeat-x). Note that you can also make the image repeat in only one direction by inserting only repeat-x or repeat-y.
You can also, instead of images, insert color as background. The "background-color:9EB4FF" gives a the specified color to the background. Note that you can add backgrounds to other tags too. Like: table, td, b, u, i, h3...Final notes:
This is good way to make a web page more interesting and keep it away from the default white background. Remember that the images you use as background can be designed by yourself.
| | Comment rules