?
Solved

path of image file in css

Posted on 2014-09-04
8
Medium Priority
?
210 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 84

Accepted Solution

by:
Dave Baldwin earned 2000 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 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 2000 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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
LVL 84

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 84

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 84

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

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
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