• Post category:HTML

What is Usage of Base tag in HTML

Base tag in HTML

In this article, we will discuss what is the usage of HTML base tags. HTML <base> tag specifies the base URL for all the relative URLs in a webpage. It is always added inside the <head> section and it is the first element inside the <head> section. So, that other elements in the head section use the information of the base element. You can add only one base element to a web page. It does not support any event attribute and the base tag does not have any end tag. It has two attributes called “href” and “target”. Inside the href attribute, we have specified the URL and inside the target attribute, we have to specify the target of all the hyperlinks on the web page.

How the base tag is work

<base href="C:/image/">
<img src="bullet.jpg">


 base tag in html
Let us consider this example, inside the body tag we have to add the image tag but as you can see inside the “src” attribute we have only specified the name of the image but we don’t specified the path. How does the src tag finds the correct path of the image we may have another image file named “bullet”. The solution is: The image src attribute will use the path given in the “href” attribute of the base tag


Leave a Reply