Log in

View Full Version : Can you use a div as a background?



Geezer D
10-29-2008, 04:49 AM
Hi, all.

I was just thinking about a crazy idea, wondering if it's possible.

Can a div be used to have all the characteristics of the background?

What I'd like to try is to have a div filled with a paragraph or 2 of big, lightly colored, justified text, that fills the entire screen, and won't affect the scrollbars, and will wrap to fit the users viewport, revealing more of the text if the user has a big screen.

Possible?

Medyman
10-29-2008, 01:12 PM
Sure, it's possible. It's quite simple really. All you have to do is add height:100% and width:100% to it's style attributes.

But, I doubt it's necessary. You can style the <html> and <body> tags in much the same way as you would a div. So, I'd suggest adding the styling you would to a <div> and add it to the <body> tag. It'll reduce your markup.

The trick would be to add overflow:hidden to your <html> and<body> tag's styles.