Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

HTML <base> Tag

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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 the base tag is “www.xyz.com” and then every other URL on the page will be prefixed by, “www.xyz.com/”.

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.
     

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 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”. 

HTML




<!DOCTYPE html>
<html>
  <head>
    <!-- Declaring the BASE URL -->
    <base
      target="_blank"
    />
  </head>
 
  <body>
    <img src="1-95.jpg" width="400" height="250" />
  </body>
</html>

Output: 
 

Supported Browsers:

  • Google Chrome
  • Edge 12 and above
  • Internet Explorer
  • Firefox 1 and above
  • Opera
  • Safari
My Personal Notes arrow_drop_up
Last Updated : 20 Jul, 2022
Like Article
Save Article
Similar Reads
Related Tutorials