Saturday 7 May 2011

HTML URL TAG

URLs are also known as Uniform Resource Locator .They are the address that you provide in the address  bar . They provide links to the other pages on the web or on your own website . URL tags in HTML are used in three different ways .


fully qualified URL - They consist of scheme , domain name and path .

e.g.
http://tutorials-pedia.blogspot.com/2010/09/xhtml-tutorials-and-tags.html - In this case

http: - scheme

//tutorials-pedia.blogspot.com - domain name

 /2010/09/xhtml-tutorials-and-tags.html- path


absolute link - Only the path portion of the address is placed in the href value .It begins with the website’s root (/) .

relative link - Relative links use the context of the current location of web page to infer the complete URL .

Consider a file structure in your computer as

      a.html
      b.html
      ABC(folder)
         c.html(file)
         d.html
      DEF
         e.html
         f.html


If I am currently at a.html and i want to visit b.html I can refer to it as

<a href="b.html">b</a>

To refer to c.html from a.html

<a href="ABC/c.html">c</a>


If I am currently at c.html but I have to refer to a.html then

<a href="../a.html">a</a>

../ - moves us one folder level up from current folder .


Use of relative or absolute links prevents typing of domain name over and over again and makes the site more portable in case domain name changes in the future.

No comments:

Post a Comment