How can I accurately reference my stylesheet?

Here's the way my site's organization looks:

root
     css directory
     images directory
     app folder 1
     app folder 2

In my app folder, I'm referring to my stylesheet.css located in my css directory like this:       

<link href="../css/new_style.css" rel="stylesheet" type="text/css" />

Works great! All my fonts, margins, divs - everything is fine. The problem, however, is that none of my images show up because I'll have a background image in my stylesheet referenced as:

background-image: url(../images/background.jpg);

But because I'm sitting in my "app folder 1" directory, that URL doesn't work.

I realize I could probably change the URLs of my background images to an absolute value rather than a relative one, but it seems I saw a technique using "_DIR_" that remedies all of this.

I might be wrong, but I wanted to see if there was a way to code the reference to my stylesheet.css where any image url was handled correctly.

Thoughts?
brucegustPHP DeveloperAsked:
Who is Participating?
 
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
Yes.  Just use...

background-image: url(/images/background.jpg);

The single slash makes it relative to the web root.
0
 
COBOLdinosaurCommented:
Uhm.... Why is this posted in the PHP topic?  It has zero to do with PHP.

Cd&
0
 
brucegustPHP DeveloperAuthor Commented:
Got it!

Thanks!
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.