Question:
can anyone direct to an online resource that clearly explains paths in HTML please?
?
2014-07-30 15:55:47 UTC
the manual I'm using calls this an absolute path, when in reality it seems relative to me:

Some Page

Unless I or the manual is googy (or both), you can access a file anywhere on that domain by simply using the forward slash, and giving it's name. I can't understand the usage of absolute here.

Ok, whatever. I just wish I could find a decent but THOROUGH treatment of this issue. Nothing I've viewed thus far clarifies anything.
Five answers:
adaviel
2014-07-30 21:57:16 UTC
Absolute: http://www.example.com/some/page.html

Relative: somepage.html, images/someimage.png, ../script/some.js

Site absolute: /some/page.html

You might use absolute URLs to refer to pages on a different domain, relative URLs to refer to pages within a project, and site absolute to refer to sitewide resources like company logos or shared script libraries. Then if you move your project to a different directory or disk, things will still work.

The site absolute path is relative to the webserver document root, which is usually different for each website (virtual host) on a physical server (or nowadays, virtual machine)
2014-07-30 16:21:49 UTC
A forward slash is calling the absolute path to your site. But of the file you are viewing is NOT in the root directory it does not work. If you are in a lower level directory you require to use ../ to go to a higher level and then down a different path. Very unclean programming though. I suggest you use the W3Schools site for all your web design.
Chris
2014-07-30 16:17:51 UTC
The path starts with a slash, which is kinda in between.



A relative path starts with a folder name, or it's just the file itself.

Absolute paths are usually full URLs, starting with the protocol part (http://).

However, if the link target is on the same server and uses the same protocol, you can start the absolute path with a slash instead. A single slash on linux means "root folder".

So if you're on site.com/about/about.html, the link you posted will link to site.com/somepage.html, making it an absolute path.
Steve D
2014-07-30 16:06:45 UTC
Your understanding is incorrect An absolute path is the complete path (i.e., http://www.mydomain.com/index/first.page.html) to get to a specific file. A relative path is the URL relative (beginning) from where you are currently. Using your example of somepage.html, if that file was located in the same folder as where you are starting, your code would find that file and display it/run it/whatever. However, if that file was in a different folder from the file you are currently running, your code/link would not find it since you have not given the link the proper location relative to where you are. Think of it this way - say you where in one town looking for Bill Smith and you asked for directions. Someone told you that Bill Smith lived on Main Street, but didn't give you any town/city. You might get lucky, go to Main Street in the town you are driving around in and find Bill, but if Bill was in the next town over, you wouldn't find Bill since you would have had to know where he was relative to you. The person should have told you Bill was on Main Street in the next town/folder over, then you would know where to look for him.
johnnycam
2014-07-30 15:57:36 UTC
W3schools

google it


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