Uses for the BASE Tag
The HTML base
tag can be used for either or both of these functionalities.
-
Place an absolute URL base at the beginning of all relative link URLs on the web page. Here are example-type definitions:
Absolute URL: https://example.com/books/sales.php Absolute URL base: https://example.com/ Relative URL: /books/sales.php or books/sales.php
-
Make a specific target attribute effective for every
a
-tag link on the web page.
Rules: Only one base
tag is allowed and the base
tag must be in the head
area of the web page source code.
Here are three examples (remember, your choice of only one may be used on a web page):
<base href="https://example.com/"> <base target="_blank"> <base href="https://example.com/" target="_blank">
The first example inserts the absolute URL base https://example.com/
into every relative link URL. This can be handy if you are developing or updating a web page on one website and will be going live with it on another web site.
The second inserts the target="_blank"
attribute into every a
-tag on the web page. This can come in handy if that is the functionality you want. There would be no need to manually insert the target
attribute into every link.
The third example does both of the above.
Remember, the base
tag must be in the head
area of the web page source code. And, only one base
tag is allowed.
(This content first appeared in Possibilities newsletter.)
Will Bontrager