Link to home
Start Free TrialLog in
Avatar of Round_Butte
Round_ButteFlag for United States of America

asked on

How do I add a background to a cascading style sheet?

I have some code of a cascading style sheet that I would like to put a back ground in the website that it references but I don't have the website it references.  I have the background image on disk, how do I code in the background image in the CSS code? John
Avatar of Jason C. Levine
Jason C. Levine
Flag of United States of America image

Hi Round_Butte,

.someclass {
                    background: url(images/file.gif)
}
To add to jason1178's solution, you can add no-repeat at the back or repeat-x repeat-y for repeating or no repeating of background image, eg:

.someclass
{
      background: url(images/file.gif) no-repeat;
}

Hop ethis helps.
If you background is for the body element (i.e. the page background on every page), then you can assign this directly to the BODY:


body {
     background:white url(somedirectory/myimage.jpg) no-repeat top left;
}

Open in new window

Hey, look who found the new code snippet feature. :)
Yes...
<opinion>
But not very useful for when I'm including multiple chunks of code!
</opinion>

Open in new window

Avatar of Round_Butte

ASKER

So I use url() regardless if its on the web or hard disk? John
ASKER CERTIFIED SOLUTION
Avatar of Joe Wu
Joe Wu
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank you
So I have to build a folder for my files????
glad to help!