Sunday, November 21, 2010

How do I set a background image with html?

I'm trying to get an image to be my background on my website..What is the html code for this, and how where do I place the image url?How do I set a background image with html?
For an image that is not tiled and is for the whole page, style with CSS this way:



body {

background: #fff url(bg_image.jpg) no-repeat center scroll;

}



That sets a white (#fff) background while image loads. It's centered and contents will scroll with background image. Change ';scroll'; to ';fixed'; if you wish contents to scroll over the background image.



For an image slice to be tiled as a background image:



body {

background: #fff url(bg_image.jpg) repeat top left scroll;

}



If you are adding a background image using any of the above ways to a container div, then:



div#wrap {

width: XXpx;

height: YYpx;

margin: 0 auto;

background: #fff url(bg_image.jpg) no-repeat center scroll;

}



Then after opening body tag:



%26lt;div id=';wrap';%26gt;



Page contents here.



%26lt;/div%26gt;



Do same for the code using a sliced image (or tileable) in a div container.



RonHow do I set a background image with html?
Here is the code:



%26lt;style type=';text/css';%26gt;

body {

background-image: url(Image url goes here);

}

%26lt;/style%26gt;



Put this code between the head section of your site,

Example:

%26lt;html%26gt;

%26lt;head%26gt;

%26lt;title%26gt;yahooa%26lt;/title%26gt;

%26lt;style type=';text/css';%26gt;

body {

background-image: url(Image url goes here);

}

%26lt;/style%26gt;

%26lt;/head%26gt;

%26lt;body%26gt;

%26lt;/body%26gt;

%26lt;/html%26gt;



-FireDart
in the body tag:

%26lt;body bgimage=';filename.ext';%26gt;



very simple,

.ext just means the extension such as .jpg or.gif etc.

No comments:

Post a Comment