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
Round_ButteAsked:
Who is Participating?
 
nizsmoConnect With a Mentor DeveloperCommented:
its the relative path to your html file, so if it is in the same directory then just put url(myimage.jpg). Essentially everything is on the hard disk it is just how you reference to the file.
0
 
Jason C. LevineNo oneCommented:
Hi Round_Butte,

.someclass {
                    background: url(images/file.gif)
}
0
 
nizsmoDeveloperCommented:
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.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
RouchieCommented:
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

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

Open in new window

0
 
Round_ButteAuthor Commented:
So I use url() regardless if its on the web or hard disk? John
0
 
Round_ButteAuthor Commented:
thank you
0
 
Round_ButteAuthor Commented:
So I have to build a folder for my files????
0
 
nizsmoDeveloperCommented:
glad to help!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.