HTML5 > Structures

Base in HTML5

How to specify the base URL for all relative URL in a document in HTML5?

By using <base> tag we can specify the base URL/target for all relative URL in a document. There can be maximum one <base> tag in a document, and it must be inside the <head> tag.

    <base href="" />

        <a href="/abbr.htm">Abbreviation tag</a>
        <a href="/article.html">Article</a>
        <a href="/articles/show/3112/progressive-continuous-loading-using-jquery">Something is good</a>
        <a href=""></a>

In the above code snippet we can notice that <base> tag which represents the base URL ( is placed inside the <head> tag, and all the relative URL's is placed inside the  <body> tag by using <a> tag.

When above code snippet runs in the browser, top 3 links target web pages on as the path is relative and 4th link simply goes to as the href attributes set its path starting with "http://".


 Views: 1152 | Post Order: 64

Write for us

Hosting Recommendations