Search code examples
htmlradix

Difference in paths for the base tag?


I'm using the base tag

<base href="http://my_domain.com/web/source/" target="_blank">

but the domain will vary so I want to use

<base href="/web/source/" target="_blank">

or

<base href="web/source/" target="_blank">

Which one should I use. Obviously I could just try both, but I want to understand why I should use the appropriate one.

Per, Mozilla, both absolute and relative paths are allowed. The docs say see note selection below but I see no note section.


Solution

  • Keeping the preceding slash (/) will always ensure that the browser goes back to the root of the domain.

    Leaving out the preceding slash could potentially send your users to /web/source/web/source/page.ext.