HTML base Tag

HTML base Tag defines a base URL for all the links on the HTML Document or Web Page.

Syntax of HTML base Tag

The Syntax of HTML base Tag is shown below. It is self closing tag. While in XHTML it has both starting and ending tag.

<!DOCTYPE html>
<html>
<head>
<base href="https://www.howtocodeschool.com/">
</head>
<body>
</body>
</html>

Usage of HTML base Tag

HTML Base Tag defines the base url or target for all other urls or links defined in the HTML Document or Web Page. There is only one base url allowed in one web page. There can't be more than one base urls.

Example of HTML base Tag

Simple example of base tag is given below.

<!DOCTYPE html>
<html>
<head>
<base href="https://www.howtocodeschool.com/">
</head>
<body>
<a href="html-base-tag.html">HTML Base Tag</a>
</body>
</html>

In the above example as you can see, the Base Url of HTML Base Tag link is defined in the head section of document.

Browser Support for HTML base Tag

HTML Base Tag is supported by all major browsers including Internet Explorer.

Attributes used in HTML base Tag

Two main attributes defined inside HTML base tags are href and target attributes. If href is not defined in base tag then target attribute must be defined or you can define both.

href attribute

It sets the Base URL of web page or document.

target attribute

It defines the target of where to open the linked document or page or file.

Global Attributes Support in HTML base Tag

The HTML Base Tag supports Global Attributes.

Event Attributes Support in HTML base Tag

The HTML Base Tag doesn't support Event Attributes.

HTML base Tag Video

Watch our video on HTML base Tag and subscribe our Youtube Channel.

HTML Comment Tag HTML Doctype Tag HTML anchor Tag HTML abbr Tag HTML acronym Tag HTML address Tag HTML applet Tag HTML area Tag HTML article Tag HTML aside Tag HTML audio Tag HTML b Tag HTML base Tag HTML basefont Tag HTML bdi Tag HTML bdo Tag HTML big Tag HTML blockquote Tag HTML body Tag HTML br Tag HTML Button Tag HTML Canvas Tag HTML Caption Tag HTML Center Tag HTML Cite Tag HTML Code Tag HTML Col Tag HTML colgroup Tag HTML data Tag HTML datalist Tag HTML dd Tag HTML del Tag HTML details Tag HTML dfn Tag HTML dialog Tag HTML dir Tag HTML div Tag HTML dl Tag HTML dt Tag HTML em Tag HTML embed Tag HTML fieldset Tag HTML figcaption Tag HTML figure Tag HTML font Tag HTML footer Tag HTML form Tag HTML frame Tag HTML frameset Tag HTML Heading Tags HTML head Tag HTML header Tag HTML hr Tag HTML html Tag