banner
Welcome to HTML.co.uk, the number one resource for all news, information, and happenings regarding HTML.

Updates: HTML.co.uk has just been relaunched. Subscribe to our RSS Feed to stay on top of HTML news and techniques.
Jun
3rd

Absolute and Relative URLs

Author: Editor | Files under HTML Tutorials
Tags for this article: , , , , , ,

As discussed earlier URLs (Uniform Resource Locators) are the addresses of all the links and resources which are globally hosted on the World Wide Web. A web page address like http://www.yahoo.com is a URL. It shows you the home page of Yahoo. In other words, it redirects you to a new URL. URL is one of the most vital elements of HTML. Without URL we cannot access any website. Every URL on the world wide web is unique and different from other to avoid confusion and clashing between the web pages of different companies. The URL consists of all the necessary information required to find out a particular web page on the internet. In HTML whenever we create a hyperlink, we associate a URL with it so that whenever a person clicks on that link, he can be redirected to the intended web page. The URLs are inserted in the HTML codes with the help of anchor tag. We can either specify an Absolute URL or a Relative URL depending upon the circumstances. Let’s have a look on how these two types of URL differ form each other.

Absolute URLs: Absolute URLs are those URLs which do not depend on any kind of relationship. These URLs directly point towards the directory of a file. It represents the whole path to a filename. Thus, there is no confusion about the location of that file on the server. For example:

http://www.contentmantra.com/design/ urls.php3

is an absolute URL which specifies the whole path to the urls.php3 file which is stored in design directory. The main disadvantage of these URLs is if you move the urls.php3 file to another location, then this URL will not show you that file. Thus, the flexibility to change the structure of the web pages diminishes. Absolute URLs are used when we want to link two files which reside in different root directories.

Relative URLs: These URLs point towards a file or directory in relation to the current file and directory. The relative URLs don’t tell us about the full path to a file name. These URLs simply redirects you to the another web page which is in relation to the previous one. Thus, they are called relative URLs. These types of URLs can be used to link different files which are in the same root directory. In other words these URLs are used with those links of a web page which redirects you to another web page of the same website. If all the files are stored under the same parent directory, then both absolute and relative URLs can be used but conventionally relative URLs are used because they are short and reduce the chances of typographic errors. Apart from this, relative URLs are easy to remember and save time while designing the HTML page.

For example; suppose there is a parent directory in c:\my folders\HTML which contains two files named as Summer.html and Winter.html respectively. Now in order to link these two files we don’t have to give the full path. We can simply write as:

<a href=”winter.html”> go to Winter Page</a>

Instead of:

<a href=” c:\my folders\HTML\winter.html”>got to winter page</a>


May
28th

URLs in HTML

Author: Editor | Files under HTML Tutorials
Tags for this article: , , , , ,

URLs (Uniform Resource Locators) are the addresses of all the links and resources which are globally hosted on the World Wide Web. A web page address like http://www.yahoo.com is a URL. It takes you to the home page of yahoo. Whenever you click on a link on a web page, it takes you to another web page. Technically speaking it redirects you to a new URL. Therefore we can say that every hyperlink is associated with a URL. Generally what we type in the address bar is like yahoo.com and then the Yahoo website opens in our web browser. It does not show any errors because the DNS resolves yahoo.com in its full format automatically. Actually yahoo.com is not the complete URL. A complete URL consists of different sections each indicating important information about the web page.

Let us take a comprehensive example of a URL such as
http://www.3seas.com/html/introduction.htm.

This URL has different sub sections which are described below:

  1. Scheme: It defines the type of protocol which has been used in a particular URL. For eg; the http is the scheme which defines the type of internet service used.
  2. Host: It defines the domain host. The default host for http is www
  3. Domain: It defines the domain name which has been registered online. 3seas.com is the domain name.
  4. Port: It defines the port number on which the http service is running. It is not displayed in the URL.
  5. The default port number for http is 80. However, this port number can be changed by the IIS administrator.
  6. Path: It shows the complete path of the directory located at the web server.
  7. File Name: It tells the name of the document whose contents are being displayed on the screen. In our example, introduction.htm is the file name.

Thus, technically we can split a complete URL as:

scheme://host.domain:port/path/filename

The domain part of the URL can also be split into logical parts. In http;//3seas.com/html/introduction.htm, The 3seas.com is the domain name out of which 3seas defines a unique entity on world wide web (also known as 1st Level domain). The .com represents the top level domain. This is used to describe the type of website. There are predefined standards which indicate the top level domains and their corresponding meanings. Some of the popular ones are:

COM It shows that the web page is intended for commercial business
2) .ORG It represents a non commercial community website
3) .NET This is used by ISPs (Internet Service Providers)
4) .MIL It is used by Military of United states only.
5) .GOV Used only by government agencies

Apart from the top level domain and 1st level domain, a domain name can also have various sub domains arranged in a hierarchy. All of them are separated by a period ‘.’ The left most represents the lowest level in domain hierarchy and the rightmost represents the top level domain. A typical example of domain name hierarchy is:

www.india.asia.nokia.com

Where india represents the lowest level in the domain hierarchy and .com represents the top level domain.

In HTML coding the URLs to a link are defined with the help of <a> tag. For eg:

<a href=””http://www.yahoo.com””>Click Here</a></p>

According to the above example you will be redirected to yahoo.com if you click on Click Here text on the web page. Although you will not find any difference whether you type the URL in upper case or lower case because the DNS server resolves that automatically, but it should be noted that the URLs are always case sensitive.