- HTML Tutorial
- HTML - Home
- HTML - Introduction
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Headings
- HTML - Paragraphs
- HTML - Fonts
- HTML - Blocks
- HTML - Style Sheet
- HTML - Formatting
- HTML - Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - <base> Tag
HTML <base> tag is used to specify base URL. There should be href and target attribute in the <base> tag.
Additionally, this element specifies how links in the current document must be opened. HTML <head> element include the only one <base> tag that can be used on the page. It must be inserted as soon as possible because its action extends at the place where it is given.
Only the first href and target attributes will be followed if you use multiple <base> element. The rest won't be considered.
Syntax
<base href="" target="">
Attribute
HTML base tag supports Global and accepts some specific attribute as well which are listed below.
Attribute | Value | Description |
---|---|---|
href | URL | Specifies the URL of a page or the name of the anchor that the link goes to. |
target | _blank _parent _self _top |
Where to open the target URL. |
Examples of HTML base Tag
Bellow examples will illustrate the usage of base tag. Where, when and how to use base tag to specify base URL.
Specifying a default URL
Following is a basic example of the usage of the <base> tag.
<!DOCTYPE html> <html> <head> <title>HTML base Tag</title> <base href="https://www.tutorialspoint.com" /> </head> <body> <img src="/cg/images/logo.png" /> </body> </html>
Default target for all links
Let’s look at the following example, where we are going to set the default target for all the URLs on the page.
<!DOCTYPE html> <html> <head> <base href="https://www.tutorialspoint.com/index.htm"> </head> <body> <p> <a href="/html/index.htm"> <img src="/cg/images/logo.png" height="39" alt="logo"> </a> <br> Tutorials Point originated from the idea that there exists a class of readers who respond better to online content and prefer to learn new skills at their own pace from the comforts of their drawing rooms. </p> </body> </html>
Base URL for multiple relative links
Consider another scenario where we are going to take the base URL, which all the relative links treat as the starting URL and opens in the same window.
<!DOCTYPE html> <html> <head> <title>HTML base Tag</title> <base href="https://www.tutorialspoint.com/index.htm"> </head> <body > <h2>List of Tutorials</h2> <ul> <li><a href="/html/index.htm">HTML Tutorial</a></li> <li><a href="/css/index.htm">CSS Tutorial</a></li> </ul> </body> </html>
Supported Browsers
Tag | |||||
---|---|---|---|---|---|
base | Yes | Yes | Yes | Yes | Yes |