Ravindra24.com

What is base href=”” target=”_blank” Tag in header part of HTML

As you are exploring <base> tag, It is used to define a default URL of hyperlinks on that document on which it is specified. If some hyperlinks dont have URL where it can be redirected, The default base URL will work in this situation.

Example

<!DOCTYPE html>
<html>
<head>
  <title>HTML Tutorial</title>
  	
  <base href="https://ravindra24.com/" target="_blank">
  
</head>
<body>

Content <a href="https://www.google.com/">Click Here</a>
<a href="">Click Here</a>

</body>
</html>

On the above example if first link will be clicked, it goes to google.com and if second link will be clicked it goes to ravindra24.com because this is defined in tag and target attribute will work as default because no anchor tag is using target attribute so it will be treated as target="_blank"

Leave a Comment