Celeritas
Celeritas

Reputation: 15033

Is an html link relative only if the value begins with http?

For example the html

<a href="www.yahoo.com">free e-mail and news</a>

Is treated relative but

<a href="http://www.yahoo.com">free e-mail and news</a>

links to yahoo.com. Is that all there is to it, the only way a link is absolute is if it starts with http or https?

Upvotes: 0

Views: 125

Answers (3)

Ravinder Reddy
Ravinder Reddy

Reputation: 23982

A URL is said to be in absolute form if it starts with any access protocol.
General syntax is:

protocol://hostname/other_information

Following are some examples of absolute URLS:

  1. http://example.org/absolute/URI/with/absolute/path/to/resource.txt
  2. ftp://example.org/resource.txt
  3. urn:issn:1535-3613
  4. jdbc:mysql://localhost:3306/test?autoReconnect=true
  5. mailto:[email protected]
  6. jar:file:/home/username/Desktop/some.jar

A Relative URL is with respect to the current path to a location either on the browser, console, or workspace.

For example
If you are on http://yahoo.com/ page and any link points to /mail rather than http://mail.yahoo.com then it is in relative to the yahoo web path.

Upvotes: 1

Akhil
Akhil

Reputation: 7600

Yes. Please Refer to the below link, which explains the Hyperlinks syntax.

HTML BASICS: HYPERLINK SYNTAX – ABSOLUTE, RELATIVE AND ROOT-RELATIVE

Absolute hyperlinks are complete addresses that contain all the elements of a URL. They always start with some version of http:// followed by the domain name (for example, www.designisphilosophy.com) and optionally a page/folder. Absolute hyperlinks are used when linking to pages outside of the current site that have a different domain name.

Upvotes: 0

The Alpha
The Alpha

Reputation: 146191

An absolute link defines a specific location of the Web file or document including: the protocol to use to get the document, the server to get it from, the directory it is located in, and the name of the document itself. Below is an example of an absolute link:

<a href="http://www.domain.com/pagename.html"></a>

With a relative link, the search engine spiders and browsers already know where the current document is located. Thus, if you link to another document in the same directory, you will not need to write out the full URL. Only the file name is necessary. Below is an example of a relative link:

<a href="pagename.html"></a>

Reference.

Upvotes: 0

Related Questions