What are the diffrences betteen Relative URL & Absolute URL


Dear friends,
In Relative URl we display the position of a file(ex:example.png) relating with the position of the current file we are working on.
Have uploaed en example,

In Absulute URL we display the position of a file(ex: example.png) relating the postion of the root folder which it belongs example.png?

If you could assist, mention an example would it better,

In which cases do we use Relative URL & Absolute URL?

Thank You


When linking to another site we have no choice but to use an absolute URL that includes the domain and the full path to the resource.

When linking to a resource on our own site, we have two choices:

  1. <a href="/folder/resource.ext">Resource</a> (absolute, starting at the site root)
  2. <a href="../../folder/resource.ext">Resource</a> (relative to current location on the site)


Hello Roy,

Thank you for your assistance,

In case we are linking to a resource of our own site, if you could mention a reason to an absoulute url rather than a relative url?

Because it seems better to uses a relative url when make conections inside our web site.


Would like to ask you if you know,

we use ā€œname attributeā€ to conect to an anchor of diffrent page of our website

Part Four

Go to Part 4

we use ā€œid attributeā€ to create an anchor into the same page of our web site

Do you know if it is corect previous explanation about usage of ā€œname & id attributesā€?
name attribute for anchors of difrent page of our web site & id attribute for anchors inside our page we are working

Thank You,


If the site is fairly shallow (meaning no deep directories) then relative is simple to write in a static site. However, as the site gets deeper and deeper, relative linking within a particular deep group of folders is fairly easy, but linking to resources far up and down other paths would be cumbersome and difficult to maintain. It would set one up for a lot of potential linking errors. Easier (and better) to just start from the root and work our way down the path.

We also need to consider generated pages. If our templates use absolute (root based) paths there is less chance of errors and less maintenance.

name attributes are seldom used on page fragments, and more commonly used in web forms. When the form is submitted, the named form controls all spill their content (values) into the POST data.

id attributes are fragment identifiers, and are anchors for links both inside and outside of the page. Recall that script can also hook a single element by id and operate on that element (or all its children) in one go.

In the very early days, before we had id and class, page fragments were identified by an empty anchor tagā€¦

<a name="history"></a>

These were page specific and could not be reached from another webpage, only from within the same page. They were clunky and quickly forgotten once id emerged.


Thank You for you assistance,


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.