build-website-header
spacer-image
 

What is a URL? -Understanding URL's

URLs (Uniform resource locators) are everywhere today. On business cards, in newspapers, emails and of course on websites. But exactly what is a URL?

URL Definition:

A URL is defined as the absolute address of a web page/resource on the Internet.

What is a URL

The above URL is an absolute URL, in that, all parts are specified. The domain name is in effect the name of the Web site or web server and is discussed in more detail in domain names.

The protocol in this case http is the hypertext transfer protocol is the one seen here and the most common one used. It is used for reading web pages on the internet. Other protocols you may see here are:

understanding-urls

Absolute versus relative URL's

Absolute URL's which specify the resource exactly as in the example above are used to access resources that are not on your Web site. If the resource is on your Web site then a relative URL can be used.

 A relative URL or relative path tells the browser the resources position relative to the current position ( web page). If we look at the file layout for our website as shown below:

what is url-2

If you are currently reading the web page create-webpage.htm and want to access the page publishing.htm then the relative path is simply--- publishing.htm-- as both files are in the same directory.

In order to access the file index.htm then the pathname is -- ../index.htm. in this case the two dots .. take the browser up a directory. To access the file image1 in the images directory then the pathname would be ../images/image1.

When accessing files on your own Web site you can use relative or absolute pathnames. When accessing web pages on other site you must always use the full pathname or absolute URL.

Links to Bookmarks or Named anchors

In order to link to a particular part of a web page then a bookmark or name anchor needs to be created in the web page. Using the above example above and assuming a book mark called middle has already been created on the publishing.htm web page, then the absolute URL to  link to this is:

URL=http://build-your-Website.co.uk/courses/publishing.htm#middle.

Where the bookmark is designated by #middle

to link to this from within the publishing.htm page then the relative link is simply:

#middle.

The ability to link to a specific location within a web page is particularly useful when dealing with large web pages. For more details and examples see below:


Related articles and tutorials:

Google
Web www.build-your-website.co.uk