In this tutorial you will learn about URL in HTML. I will also cover various prospects of using URL in HTML.
URL is abbreviation of uniform resource locator. This is a unique string of letters, numbers, words and other characters used to access specific web material. URL can redirect you to a specified content, documents, pictures, video clip, program, etc. URL is also referred to as a hyperlink.
All URL basically contains the three sections
- The name of the resource itself, which is given as a path.
- The name of the machine hosting the resource.
- The name of the protocol used to transfer the resource over the Web.
The below example will clear the concept of URL. Suppose that we have link
Each part holds a specific area in URL. Following description will explain about each component in URL.
(http)- This is commonly name as scheme, defines the type of Internet service
(www)- this part defines the domain host for http
(abcdef)- This part holds the Internet domain name, such as facebook.com or twitter.com.
(: xyz)- This part will holds the port number at the host such as http will take 80 port no by default.
(pqrs): This part describes the path name of any file or documents stored on server side.
(document_name): document_name will defines the name of a document/resource
This is important to know that URLs are case-sensitive. There may be some URLs, or parts of URLs, where case doesn't matter, but identifying URL is not easy. Users should always consider that URLs are case-sensitive.
All web pages have a web address (https://www.abcd.com/pages/number/file_name.html ) or URL usually contains the name of ISP (internet service provider) this is very important to know if your are inserting a hyperlink on one page, which links to a second page in the same directory, the URL used for the second page is simply the name of that document extra-for example, file_name.html
There are basically two types of URL:
Relative URL shows from where the current page is relating to resource. For example /html/html_video_links.htm
A relative URL doesn't contain any protocol or machine information, and its path generally refers to an HTML document on the same machine as the current document. Relative URLs may contain relative path components.
An absolute URL is the complete address of a resource, everything your system needs to find a document and its server on the Web.
There is one more concept related to relative URL, Resolving URL. Basically resolving a URL is the process of taking a relative URL and obtaining the absolute URL.
URL in HTML:
URLs play vital role in HTML you can see URLs in various parts of HTML programming. These are the areas where URLs appears in HTML:
- Linking to another document or program, we use generally base, a, link, area, form, input, script etc.
- When including an object directly in a document, you can see IMG, Frame element.
- When referring to metadata describing document. You can see as a example head section of HTML program. A simple script will clear the all concepts related to URLs in HTML.
Listing 1: HTML URL Script
Figure 1: Above figure is output of a simple program of HTML in which various section are discussing URLs in HTML.
The above example have a meta tag with a url, and this meta tag have a property to refresh the page in every 3 seconds. When the page will refresh first time, it will redirect the page to url given in meta tag.
Example also gives an idea to add image by giving the relative URL, not a full path. The code is just having src="facebook.png", it means image is in the same directory in which html page is residing.
You can also see the example of absolute path in: href=http://www.facebook.com. Here href contains the full path of facebook first page.
I have covered the basic understanding of URL and locating the specific resource. I would recommend you that understand the example given with this tutorial and let us know your questions by commenting at mrbool site.