HTML Base Tag Example
The base tag in HTML is used to specify a base URL for a website’s all relative URLs. The base element in HTML used to set the base URL for the relative URLs on the document. It can be a confusing thing in the end but it is there to use if someone require using this. To understand the base tag more let’s see the code below. There is maximum one HTML <base> tag in a document and include it in the head section of a document.
HTML code example for bas tag
<meta charset=”UTF-8″ />
<base href=”http://ilmiweb.weebly.com/” />
HTML base element or bas tag
This page is at based at http://ilmiweb.weebly.com/
Here is a relative link to <a href=”contactus.html”>Contact Us</a>.
The code is very simple and easy to understand. In this code we are having a <base> tag in the head section of the page. The HTML <base> tag is having an attribute of href which is specifying the base for the relative URLs in this document. In the body section we are having a paragraph which is containing a link to contactus.html page. When you will run this code in the browser in will show the link as it normally does. When you click on the link it will take you to the contactus.html on ilmiweb.weebly.com. It will search for the contactus.html in this website. It means that whatever the relative link is it will be searched by the browser in the web address specified in the <base> tag.
The HTML base tag or base tag in HTML is somehow useful for a development environment. It should be used carefully in production environment if you want use it, because it can be a difficult thing to handle for a person who is working on the document for the first time. So we recommend you to avoid using this in a production environment for the sake of clearness.
Try to include the HTML base element or HTML <base> tag right in the top of head section. This will allow other elements in the head section as well to use the <base> tag information further.