html tutorial - Base <base> tag in HTML - html5 - html code - html form
Learn html - html tutorial - base tag - html examples - html programs
- <base> element is used for the base URL for all relative documents in the HTML page.
- Only one base element is used inside the <head> element in HTML document.
- <base> tag supports Global attributes.
- <base> tag belongs to Metadata Content category.
Syntax for <base> tag:
Sample Coding for <base> tag:
Code Explanation for <base> tag in HTML:
- In the <base> tag “href=http://www.wikitechy.com/” is base URL for all the related URLs in the documents.
- <a href="online-tutorials"> this will be navigate to “http://www.wikitechy.com/online-tutorials”. If we cannot set the
tag URL that will be navigate to the “online-tutorials” document in the current directory.
Note: <base> tag is declare within the head element only.
Output of <base> tag:
- If user click the “Wikitechy online tutorials” link that will be redirected to Wikitechy online tutorials page in wikitechy.com website.
Attributes of <base> tag in HTML:
Attribute | Value | HTML4 | HTML5 | Description |
---|---|---|---|---|
href | URL | Yes | Yes | Denotes the base URL for all relative URLs in the page |
target | _blank _parent _self _top framename |
Yes | Yes | Denotes the default target for all hyperlinks and forms in the page |
Browser Support for <base> tag:
Yes | Yes | Yes | Yes | Yes |
Tips and Notes
- The <base> tag is the first element inside the <head> element, so that other elements inside the head section uses the information from the <base> element.
- The <base> tag is present, it must have href or a target attribute, or both.