HTML “ < base > ” tag (tag)-Set the base URL, base target of the link in the webpage
<base> is used to set the default root URL (base URL) and default link target (base target) of all link type attributes in the entire page. What is the link type attribute? For example, there are href of <a> hyperlinks or src of <img> pictures .
<base> tag has two attribute values href
and target
.
<base> is href
used to set relative paths for all the root URL, for example:
<head>
<base href="https://examples.com/somedir/">
</head>
<body>
<a href="some/place.html">This link</a>
Will connect to https://examples.com/somedir/some/place.html
<a href="/another/place.html">This link</a>
Will connect to https://examples.com/another/place.html
<a href="https://www.fooish.com/html/base-tag.html">This link</a>
No change, will connect to https://www.fooish.com/html/base-tag.html
<a href="#some-id">This link</a>
Will connect to https://examples.com/somedir/#some-id
<img src="images/photo.jpg"> This picture
Will connect to https://examples.com/somedir/images/photo.jpg
</body>
<base> is target
used to set a default link target, target can be specified the following values:
_self
: Default value, open in the current window_blank
: Open in new window_parent
: Open in the parent window of the upper level_top
: Open in the topmost parent window
for example:
<head>
<base href="https://examples.com/somedir/" target="_blank">
</head>
<body>
Click on
<a href="some/place.html">This link</a>
Will open a new window And connect to https://examples.com/somedir/some/place.html
</body>
Post a Comment
0 Comments