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.

Attributes

The base tag supports the global and event attributes.

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

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

Examples:

<head> <base href="http://faragta.com/images/" target="_blank"> </head> <body> <img src="img.gif"> <a href="http://faragta.com">Learn HTML</a> </body>