HTML URL
What is URL?
URL stands for Uniform Resource Locator. It’s the global address of all documents and other resources found on the internet. Its primary purpose is to locate a document and other information on the internet and determine how to access it via a web browser.
For example, if you look in your browser’s address bar, you’ll see:
https://www.codinghub360.com/html-tutorial/html-url
— Here is the URL of your current web page.
The URL Syntax
The basic structure of URLs is as follows:
scheme://host:port/path?query-string#fragment-id
A URL is a list of URLs in a linear fashion and is usually composed of one or more of the following:
- Scheme name — The name of the scheme indicates the protocol that will be utilized to access the resource online. Scheme names are followed by three characters: a colon and two slashes (://). The frequently used protocols include http://, https://, ftp://, and mailto://.
- Host name — The host name is used to pinpoint the location of a resource on a host. It is a domain name given to a host computer, typically a mix of the host's local name and its parent domain's name. For instance,
www.codinghub360.com
is made up of the host's machine name www
and the domain name codinghub360.com
.
- Port Number — Servers frequently provide multiple types of services, which means you need to specify the desired service when communicating with the server. This is done through port numbers. Typically, well-known port numbers for a service are not included in the URL. For instance, the web service HTTP typically operates on port 80, while HTTPS operates on port 443 by default.
- Path — The path indicates the particular resource on the host that the user wishes to reach. For instance,
/html/html-url.php
, /news/technology/
, and so on.
- Query String — The data in the query string is sent to server-side scripts on the web server. It typically includes parameters for searches. The query string starts with a question mark (
?
) and consists of pairs of names and values separated by ampersands (&
). For instance, ?first_name=John&last_name=Corner
, q=mobile+phone
, and more.
- Fragment identifier — The fragment identifier, when included, indicates a specific location on the page. The browser can scroll to show that particular section of the page. The fragment identifier, denoted by a hash character (
#
), is the optional final part of a document's URL.
Note: The scheme and host components of a URL don't care about capitalization, but the path and query string do. Typically, the entire URL is written in lowercase.