HTML | base Tag
The HTML base tag is used to specify a base URI, or URL, for relative links. This URL will be the base URL for every link on the page and will be prefixed before each of them. For example, if the URL specified by base tag is “www.xyz.com” and then every other URL on the page will be prefixed by, “www.xyz.com/”.
Syntax::
<base href = "SAMPLE_URL" />
Example: Notice that we have only specified a relative address for the image. Since we have specified a base URL in the head section, the browser will look for the image at “https://media.geeksforgeeks.org/wp-content/uploads/1-95.jpg”. That is in the below program we have specified a base URL “https://media.geeksforgeeks.org/wp-content/uploads/” for all of the links and when we are referring to the image at URL “1-95.jpg” then the browser is actually rendering the image from “https://media.geeksforgeeks.org/wp-content/uploads/1-95.jpg”.
<!DOCTYPE html> < html > < head > <!-- Declaring the BASE URL --> < base href = target = "_blank" > </ head > < body > < img src = "1-95.jpg" width = "400" height = "250" > </ body > </ html > |
Output:
Important Points:
- The base tag must be defined between the head tags.
- There can be a maximum of only 1 base tag in a page.
Supported Browser: The browser supported by <base> tag are listed below:
- Google ChromeChrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | DOM Base Object
- HTML | <base> target Attribute
- HTML | DOM Base href Property
- HTML | DOM Base target Property
- HTML | <base> href Attribute
- Minimum height of a triangle with given base and area
- HTML Course | Structure of an HTML Document
- HTML | DOM HTML Object
- HTML Course | Basics of HTML
- HTML | <i> Tag
- PHP vs HTML
- HTML | <html> Tag
- HTML | <hr> Tag
- HTML | li Tag
- HTML | <q> Tag
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.