Open In App

GATE | GATE-IT-2004 | Question 90

Given below are several usages of the anchor tag in HTML.

  1. <A HREF = "http://www.gate.ac.in/HTML/BASIC/testpage.html">Test Me</A>
  2. <A HREF = "/BASIC/testpage.html">Test Me</A>
  3. <A HREF = "testpage.html">Test Me</A>
  4. <A HREF = "testpage.html#test">Test Me</A>

Which of the above are valid?
(A) I and II only
(B) I and III only
(C) I, II and III only
(D) I, II, III and IV

Answer: (D)
Explanation:

I is valid because the link given in href tag is a valid link. 
The link given is an absolute url and hence holds correct.
II is valid because the link given in href tag is relative url. 
It redirects the user corresponding to the domain name of the current page. 
If you are on domain name of geeksforgeeks as https://www.geeksforgeeks.org/ 
then it will take you to https://www.geeksforgeeks.org/BASIC/testpage.html and 
if you are on http://google.com/ then it will take you 
to http://google.com/BASIC/testpage.html
III is valid because it takes you to the page corresponding to the 
current url of the page. Please note that if we use / before testpage.html, 
then it is respect to domain not the complete url.
IV is valid because it takes you to the container with class/name as 
test on the same page.

Quiz of this Question

Article Tags :