HTML Tags: <base>



Somehow the <base> tag remains unknown to most of the web developers, but that’s quite normal. However let see what it can do. By adding the <base> tag in the head of the page you tell every link into that page how to open and a default href value. Thus if you have:

<base href="">

every link without a href attribute will open this link. That’s really useful in some cases. However the most interesting part of the base tag is the target attribute.


Everybody knows what will result from this attribute attached to a anchor tag.

<a href="" target="_blank">Click Here</a>

But with only adding this base tag:

<base target="_blank">

into the head … all the links will open in a new tab/window, depending on the browser preferences.

Watch out!

If you add the line above somewhere into the <body> tag the browser, will put it into the <head> which will make it difficult to track. A good practice is to place it directly into the <head>!

One thought on “HTML Tags: <base>

  1. You might be surprised how many people I’ve seen implement this incorrectly, setting the hostname portion of the URL to the server name the site runs on instead of the site URL.

    Or setting it to a URL of a dev or test site then deploying to the live servers.

Leave a Reply

Your email address will not be published. Required fields are marked *