Definition of URL with Examples

HTML tutorials

What is URL? |What is URL used for in html?

what is url mean

URL stands for Uniform Resource Locator. It is used to specify the location or address of a resource on the internet. The resource could be a file, a page or a web service. In the Internet you will be dealing with these all the time. The URL or the Uniform Resource Locator is composed of a few elements. To illustrate more here is an example URL.

HTML Code Example:

http://www.howtocode.pk:80/object?query#location

In the above code we the starting part (http) is called the “scheme”. It specifies the protocol and the use. There are two types of schemes used for web pages are the http and https. Most of the browsers display the pages with scheme and some don’t. The scheme is always followed by the (://) colon and double slash.

After the scheme component of the URL, starts the host name. It is the name of the place where the required resource is allocated. It could be the IP address of the server hosting the resource.

After the host name or IP address, comes the port part of the URL. Here in the above demo URL we have (:80) 80 it is the TCP port number. It can be omitted as it is default to the scheme specified in the scheme field.

Next we have the path part of the URL. It is the path to the object you are specifying. It always begins with a forward slash as we have in a UNIX file path name. It is not allowed in many servers to put back slash like we use in the Windows file path name.

Then we have the Query String a well renowned term to web developers. It is passed to the software running on the server. It is typically used for a CGI query. It can provide a number of a named value pairs.

On the end we have the Fragment Identifier. It is used to go to the file with in the page or other resource. Here are some more examples for URLs.

HTML Code Example

http://www.howtocode.pk/

The above URL shows that it is the address of the root directory of host name. If you omit the end slash it would cause nothing.

HTML Code Example

http://www.howtocode.pk/images/

In the above code we have the path with the host name. This is the path of the files in the images directory on howtocode.pk.

This “/images/” is a relative URL. If you will put it in a link on a page the browser will put the host name in front of it and will complete it. The other way of specifying a relative page is as “contact.htm” etc.

Learn more about HTML with more HTML tutorials here on HowToCode.pk.

Comments