?
Solved

How can I accurately reference my stylesheet?

Posted on 2015-01-14
3
Medium Priority
?
65 Views
Last Modified: 2015-01-14
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?
0
Comment
Question by:brucegust
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 40549808
Yes.  Just use...

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

The single slash makes it relative to the web root.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40549911
Uhm.... Why is this posted in the PHP topic?  It has zero to do with PHP.

Cd&
0
 

Author Comment

by:brucegust
ID: 40549934
Got it!

Thanks!
0

Featured Post

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question