Solved

path of image file in css

Posted on 2014-09-04
8
208 Views
Last Modified: 2014-09-05
Hi,

What is the difference between using /, ../ and ./?
I have a folder structure
project
     src
     webapp
             js
               css1
                        images3
           css2
            images1
            style1    
                    css1
                          a1.css

what is the best way to refer images in images1 folder from a1.css ?
0
Comment
Question by:Rocking
[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
  • 5
  • 3
8 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 40305040
Here http://en.wikipedia.org/wiki/Path_%28computing%29 is probably more than you wanted to know.  '/' is your home directory.  In a web site this can mean your web site home directory and not your user home directory.  './' is the current directory and '../' is the next higher directory in the current path.
0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 500 total points
ID: 40305042
The most reliable way to refer to the images1 directory is "/project/ webapp/images1/img.jpg" because that path starts at the root of your directories and will always work from anyplace in your paths and directories above.
0
 

Author Comment

by:Rocking
ID: 40305884
What is the difference between using /, ../ and ./?

can i make ""/project/" as dynamic?
0
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40306523
can i make "/project/" as dynamic?
What does that mean?  Whatever you use for a 'path' to a file has to match what is actually on the server.
0
 

Author Comment

by:Rocking
ID: 40306563
suppose the name of the project changes then if i have hardcoded the project name,then it needs to be changed manually.
like in jsp we get teh context path same way can we get in css also? If yes then how?

If we can't get the context name in css file then the approach ../ would be much better as the project name changes we don't need to modify the project name in css file.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40306640
CSS is entirely passive, it is a description language but not a programming language.  Some other language would have to change the 'project' name because there is nothing in CSS that can do that.
0
 

Author Comment

by:Rocking
ID: 40307142
ok it means that there are no ways in which we can pass the project name in the css file.

It means that the approach ./ will be the best if we need dynamic folders.

Can u please let me the know the difference between "using /, ../ and ./?"

Out of the tree which one is better ot use
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40307151
The three methods, " /, ../ and ./", are not interchangeable, they are used for different things.  Usage depends on the need and where the file is in the path structure.  See my first comment for details.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Find out what you should include to make the best professional email signature for your organization.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

724 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