Well-known tag, but here I met this: description of the base tag from the developers of Mozzila (MDN project)

But what does it mean when the href tag attribute points not to a directory address, but to the address of a particular file?
Assume <base href="http://www.example.com/page.html">
What is it for?
What does this move mean?
On some sites I saw (on CMS Joomla)

    2 answers 2

    Because it also affects the anchors. It would be strange to count them from the folder, not from the page.

    <base href="http://thisrocks.com/app/">

    When using <base> you may encounter the problem of links to intra-page anchors.

    Usually a link like <a href="#top">Наверх</a> will leave you on the current page, but will transfer to the element with id="top" , that is, it will link to http://thisrocks.com/app/article.html#top .

    But if you use a tag with the given href attribute, then you will be redirected to the base URL with the #top segment added to the address, that is, http://thisrocks.com/app/#top .

    In this case, you also need to override the defaults set by the tag, specifying the page to which your anchor belongs, that is, <a href="article.html#top">Наверх</a>

    A source

    • Only anchors do not cause transitions between pages. Accordingly, it doesn't matter what the base of the document is (no HTTP session will be anyway) - tutankhamun pm
    • @tutankhamun, the transition will be. Open (if you're not in IE) data:text/html,<!doctype html><title>Demo</title><base href="http://google.ru"><a href="#">Go</a> and click on the link. - Qwertiy
    • one
      Shaitan! I sprinkle my head with ashes. +1 in turnips - tutankhamun

    The same implies. Just a base for relative links. In fact, such a link may (or should) point to the address of the document itself. This is convenient when the document is saved to disk (relative links do not stop working)