HTML URL Encode

HTML Uniform Resource Locators (URLs)are used to identify resources such as web pages, images, videos, and other files on the internet.

URLs are composed of several parts, each with a specific purpose.

URLs are composed of several parts, each with a specific purpose.

Protocol:

The protocol defines the method used to transfer data between the client and server. The most commonly used protocol is HTTP, which stands for Hypertext Transfer Protocol. Other protocols include. HTTPS, FTP, and file.

Domain:

The domain or hostname is the name of the server that hosts the resource. It can be an IP address or a domain name such as www.example.com.

Path:

The path specifies the location of the resource on the server. It can include one or more directories and the name of the file.

Query Sctring:

The query string is used to pass data to the server. It follows the path and is separated by a question mark (?). It consists of one or more name-value pairs separated by an ampersand (&). For example, in the URL "http://www.example.com/search?q=HTML",the query string is "q=HTML".

Fragment identifier:

The fragment identifier specifies a specific section of the resource. It follows the path and query string and is separated by a hash symbol (#).

Here's an example of a URL:

<p>https://www.example.com/products/1234?color=blue#reviews</p>

In this example, the URL consists of the following parts:

  • Protocol: HTTPS
  • Domain: www.example.com
  • Path: /products/1234
  • Query string: color=blue
  • Fragment identifier: reviews

URLs can be used in HTML for linking to other pages or resources on the internet. For example, the <a>element is used to create a hyperlink:

<ahref="https://www.example.com">Visit Example Website&#945</p>

It is important to set the charset attribute correctly in order to avoid character encoding issues that can cause problems with displaying special characters or non-English text on the webpage.

HTML Form is very important when it comes to working with URL in the website you will learn more about it in the next chapter.