HTML base - how to use <base> tag

The <base> tag defines the root URL that all other relative URLs within the document can use. A HTML file can contain 1 <base> tag only and it needs to be within the <head> tag. The <base> tag should be the first element within the <head> tag to allow other elements from the head tag to use it.


The base tag supports the global and event attributes.

This indicates the root URL for all other relative URLs within the HTML file.
This indicates the default target type for all links within the HTML file.

The <base> tag must have either the href and target attribute.


<head> <base href="" target="_blank"> </head> <body> <img src="img.gif"> <a href="">Learn HTML</a> </body>