Head: Base Tag

The <base> element specifies the base URL and base target for all relative URLs in a page. This can help browsers to more quickly find elements needed to display the webpage:

<base href="http://www.w3schools.com/images/" target="_blank">
HTML file: Displayed by browser:
<base href="http://www.w3schools.com/images/" target="_blank">
<body>
<img src="html5.gif">

<p>Since we have specified a base URL, the browser will look for the image <b>html5.gif</b> at <b>http://www.w3schools.com/images/</b>.</p>

<p><a href="http://www.w3schools.com">W3Schools</a></p>

<p>The link above opens in a new window because the base target is set to <b>"_blank"</b>.</p>
</body>

Since we have specified a base URL, the browser will look for the image html5.gif at http://www.w3schools.com/images/.

W3Schools

The link above opens in a new window because the base target is set to "_blank".

Hmmmm... well, this was a tricky thing! My green buttons are not located at the base URL, so they didn't display at first. Obviously I cannot use the tag, if I want my buttons to show. I suppose the tag is only good if you use an outside storage URL for images, CSS files, or other files that you refer to from your webpages. That could get confusing!

Back button Table of Contents Next button