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 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 comment 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 Doctype 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 HTML i Tag HTML iframe Tag HTML img Tag HTML input Tag HTML ins Tag HTML kbd Tag HTML label Tag HTML legend Tag HTML li Tag HTML link Tag HTML main Tag HTML map Tag HTML mark Tag HTML meta Tag HTML meter Tag HTML nav Tag HTML noframes Tag HTML noscript Tag HTML object Tag HTML ol Tag HTML optgroup Tag HTML option Tag HTML output Tag HTML p Tag HTML param Tag HTML picture Tag HTML pre Tag HTML progress Tag HTML q Tag HTML rp Tag HTML rt Tag HTML ruby Tag HTML s Tag