The GATE Grind

GATE 2015 CS (CS3) – Question 18

Computer Networks · Application Layer: DNS and HTTP · 1 mark · Multiple choice

Ten server pages have URLs http://www.yourname.com/var.html, with var from 1 to 10. A local edited copy of page 1 contains relative links such as "var.html". Which markup makes those links resolve to the server pages?

  1. <a href="http://www.yourname.com/", href="…var.html">
  2. <base href="http://www.yourname.com/">
  3. <a href="http://www.yourname.com/">
  4. <base href="http://www.yourname.com/", range="…var.html">

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (B) <base href="http://www.yourname.com/">

Explanation

The HTML base element sets the base URL used to resolve document-relative references. Setting its href to the server root makes a link such as 2.html resolve to http://www.yourname.com/2.html, even in a local copy. An anchor does not set the document base, and range is irrelevant. Thus B.

More Application Layer: DNS and HTTP questions

All Application Layer: DNS and HTTP questions →