htmlradix

What is the <base> element in HTML for?


I am learning how to code on w3schools.com. There is an explanation on what is for but it's not very helping. All it says is "Defines a default address or a default target for all links on a page" why do we even need to do this?


Solution

  • You normally don’t need the base element. It is sometimes used when most URLs on a page refer to a site other than the site of the page; in that case, <base href="..."> lets you use relative URLs for those; but then all other URLs must be absolute. In the past, <base target=...> was sometimes used on frameset pages in order to make link open in a particular frame.