HTML <BASE> tag

Not more than one base tag to be used inside HEAD tag of the page.
Base URL is applied to relative URL ( or Links , Image SRC ) of the page.
<base href='https://www.plus2net.com/images/' target='_blank'>

Attributes

AttributeDescription
hrefThe URL to be userd , can be relative or absolure
target_self : Default, loaded in same browser window
_blank: Open in new window
_parent: If curent one is a child window then link will open in Parent
_top: Open in ancestor of present one ( if exist )

Example : Link with target=_blank ( open in new window )

<base href=../php_tutorial/ target=_blank>
<a href=site_map.php>Go to PHP Section</a>

Example : Linking image from image directory of root.

Our image logo.jpg is placed inside image directory at root. So Base tag ketp inside HEAD tag is
<base href=../images/>
In our present directory , inside this page we have image URL like this.
<img src=logo.jpg>
Output is here
DEMO of base url

We have used relative URL here, we can also use absolute URL like this.
<base href=https://www.plus2net.com/images/>

Reading base URL

We can get base URL of the page by using this script.
<script>
var base_URL = document.baseURI;
alert(base_URL); // https://www.plus2net.com/html_tutorial/html-base-url.php
alert(window.location.origin) // https://www.plus2net.com
alert(window.location.host) // www.plus2net.com
</script>

HTML Meta Tags BODY tag

Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    Post your comments , suggestion , error , requirements etc here




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer