codescracker


html

HTML URL Encoding



« Previous Tutorial Next Tutorial »


A URL refers to a unique address the identifies each Web page on the World Wide Web (WWW). A common way to access a website is to enter its URL in the address bar of a Web browser.

The URL of a website enables you to access files, such as image files and program files, within the website. Some of the HTML elements also include the URL as an attribute value, such as the A element.

A URL can contains file name or an Internet Protocol (IP) address, such as 127.1.1.1. The most common method of providing the URL is to specify the name of the website as names are easier to remember than the IP addresses.

HTML URL Parts

A URL consists of three parts described in the table given below:

Name Description
Protocol Transfers a resource over the Web
Domain name Refers to the machine hosting the resource
Path name Specifies the path of the resource

Structuring the URL

A resource available on the Web, such as HTML documents, images, video files, and programs, has an address that is enclosed by a URL. All URLs contain a scheme, domain name, port, path, filename, and hierarchical description that specify the location of a file on the Internet.

Here is the syntax of the general URL:

scheme://host.domain:port/path/file_name?query_string#anchor

The parameters in the preceding syntax are described in the following table:

Name Description
scheme Refers to a protocol that is used to access the file resource. It specifies the type of the Internet service, such as Hypertext Transfer Protocol (http), File Transfer Protocol (ftp), and file. The most commonly used type is http
host Specifies the domain host. The default domain host for http is www
domain Specifies the Internet domain name, such as google.com or codescracker.com. The domain is also identified by a unique IP address. For example, google.co.in can be accessed by its IP address 209.85.231.104
port Refers to the port number that connects that connects a client browser to a server. Every scheme has a default port number. Therefore, if a port number is omitted from the URL, the default port number of that scheme is used. The default port number for htttp is 80
path Specifies a path (sub directory) for the server. Every Web resource (document) has the root directory of a website as the default path. If the path is omitted from the URL, it means the Web resource is located at the root directory of the website
file_name Specifies a document, information, or program. Every Web site has the default file name, index.html, which opens when the Web site loads in the browser. Therefore, if only scheme://host.domain:port/path/ is entered in the browser, it opens the default file of the Web site.
query_string Contains the data to be passed to the Web applications. The query string contains parameter/value pairs separated by the ampersand (&) symbol. In each pair, parameter and value are separated by an equal (=) symbol. The whole query string is preceded by a question-mark symbol (?). The general structure is ?parameter1=value1&parameter2=value2 ...
anchor Specifies a particular location on a Web page. For example, http://www.google.com/articles/listing#top provides the address of the beginning of the listing section of the page.

HTML schemes and Access Points

The schemes and their access points are listed in the following table:

scheme Access
file Refers to a file on the local PC
ftp Refers to a file on the ftp server
http Refers to a file on the World Wide Web server
gopher Refers to a file on the Gopher server
mailto Refers to an electronic mail address
news Refers to a usenet newsgroup
telnet Refers to a telnet connection
wais Refers to a file on Wide Area Information Servers (WAIS)

Encoding the URL

URL encoding is a process of converting the information of a URL into a valid URL format. The encoding of the URL is used to safely transmit it over the Internet. URL encoding is performed via HTML forms. The information that you want to send over the Internet may contains special characters, such as slash(/), period(.), and hash(#). Each special character is encoded, because it has on of the following possibilities :

The special characters are also known as reserved or unsafe characters. You can include a special character in the URL with the help of encoding. For example, the URLs use the / character to separate its constituent elements. If you include the / character in the URL, the character is treated as an element separator. You need to write its encoding, %2F, in the URL to include the element separator.

Special Character with Descriptions and Encodings

The following table lists the special characters, their descriptions, and encodings:

Character Description Encoding
; Semicolon %3B
/ Slash %2F
? Question Mark %3F
: Colon %3A
@ At sign %40
= Equal sign %3D
& Ampersand %26
< Less than sign %3C
> Greater than sign %3E
quot Double quote %22
# Hash symbol %23
% Percent %25
{ Left curly brace %7B
} Right curly brace %7D
| Vertical bar %7C
\ Backslash %5C
^ Caret %5E
Tilde %7E
[ Left square bracket %5B
] Right square bracket %5D
` Back single quote %60

Newsgroup and Mail System

A newsgroup is an online community and forum that discusses a particular topic of Interest. The users can read and post messages to these communities or forums about the respective subject. These messages are also called articles or posts and collectively termed as news. The moderator or controller of a newsgroup monitors all messages and articles transmitted to the computer network. All the messages and articles are organized into topics.

The example of a newsgroup is Usenet, which is a worldwide distribution discussion system. It consists of a set of newsgroups with names that are classified hierarchically. Usenet encompasses both e-mails and Web forums. A discussion group on Usenet is dedicated to one topic. Usenet is the group of people who interchange the articles tagged with one or more universally recognized labels, called newsgroups. HTML provides the href attribute to access a newsgroup.

Mail system are based on the store-and-forward model used to exchange the digital messages. In the store-and-forward model, a mail server accepts, delivers, and stores messages on behalf of users. The only pre-requisite to use the mail system is the connection with the network-enabled device at the time of message submission or retrieval.


« Previous Tutorial Next Tutorial »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test