Base Tag in HTML 5

Rahul Ahir
2 min readApr 29, 2023

--

Base Tag in HTML 5

The <base> tag in HTML5 is an optional element that is used to specify a default URL and a default target for all links on a web page. It is typically used within the <head> section of a web page, and can only be used once per page.

The <base> tag has two attributes:

“href” and “target”. The “href” attribute is used to specify the default URL for all links on the web page, while the “target” attribute is used to specify the default target for all links on the web page.

The basic syntax for the <base> tag is as follows:

<base href="http://www.example.com/" target="_blank">

In this example, the <base> tag is used to specify that all links on the web page should be opened in a new window (_blank) and the default URL for all links on the web page is “http://www.example.com/".

The <base> tag can be useful in situations where you want all links on a web page to point to a specific location, such as when you are working on a development version of a website or when you want to move a website to a new domain.

It is important to note that the <base> tag only applies to relative URLs, not absolute URLs. URLs that are specified with a protocol (http, https, ftp, etc.) or a domain name are considered absolute and will not be affected by the <base> tag.

--

--

Rahul Ahir

YouTuber @ahirlog | Flutter Developer | Digital Creator