Starting with a forward slash in html for “href”

Is one a relative path and one an absolute path?

Yes.

If your browser is currently pointing at http://foo/bar/baz.html then:

  • <a href="https://stackoverflow.com/questions/10659459/reset/index.html"> would link to http://foo/bar/reset/index.html.
  • <a href="https://stackoverflow.com/reset/index.html"> would link to http://foo/reset/index.html.

If there is a base element in the head of your HTML document then the relative path will be relative to the base. For example the link here will take you to http://example.com/foobar/reset/index.html regardless of where the page is located.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
 <HEAD>
   <TITLE>Base element example</TITLE>
   <BASE href="http://example.com/foobar/">
 </HEAD>

 <BODY>
   <P><a href="https://stackoverflow.com/questions/10659459/reset/index.html">Reset CSS</a>
 </BODY>
</HTML>

Leave a Comment