Question:
Can an html file reference a move able folder?
SkellingtonJack
2013-09-04 15:11:49 UTC
I have built a basic website for school. It references a css file and a few picture files from a common folder. We are required to transfer the folder to the school computer so we can present it. I have already witnessed a few of my classmates Presentations where they had to go up 15 min or so before their presentations so that they could change the location of the css and images. Is there a way that the html can be linked to a move able folder? I'm almost positive there isn't but just in case :-) also assuming there isn't, is there a quick trick to change all of the addresses in your html file?
Five answers:
anonymous
2013-09-04 16:26:24 UTC
See: Absolute and Relative Paths (Using URLs Effectively) - http://webdesign.about.com/od/beginningtutorials/a/aa040502a.htm



Ron
?
2013-09-04 22:20:50 UTC
Ideally what you would want to do is use a relative URL when linking your images/resources. So long as the relative structure of the folders is intact, then the links should still work.



So, if the "common" folder was something like C:\common\img\

And your CSS file is C:\website\mysite\css\style.css

Then in style.css, you should refer to ..\..\..\common\img\commonimg.jpg



You might be having a different situation though (your question wasn't too clear about what you meant by moving things), so if you could elaborate, that would be best.



As for changing all the addresses, if you know where the location of the new directory is, then all you have to do is a find-and-replace search by searching for the old directory path and replacing it with the new directory path.
Daniel B
2013-09-04 22:22:11 UTC
What you are looking are relative paths as opposed to absolute paths. For example if you CSS is linked like this:







It will probably not work when moved to another computer. If your HTML file is in the mysite directory you can use a relative path instead:









This will look for a directory called css in the same folder as your HTML. As long as the css directory is there this will work no matter where you move the site.
Robert
2013-09-04 22:19:09 UTC
If you use relative addressing with HTML like







everywhere you can avoid having to change lots of URLs in the sense that if you are uploading a whole lot of files at once to another place in order for you to do your presentation, you might be able to keep the same directory structure. Whereas if you have absolute addressing like below







it may not be so easy, and yes, you would have to change lots of URLs in your HTML/CSS/Javascript.
?
2013-09-04 23:40:21 UTC
Hello



Your html file can be uploaded, and downloaded to, and from a folder.

If an FTP server is setup, and you have permission to use it, then you can transfer your html file directly to your school's computer. You can't link an html file to a folder.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...