Base Tags in HTML5

Introduction 

 
A Base tag provides a default (base) URL or relative links. It is usually used to set a default URL for all subsequent relative links. Relative links can be a stylesheet, source of script tag and hrefs in the anchor tag. In simple terms, you can say a base tag sets a default address or a default target for all links on a page.
 
One important thing that you should always remember is that a base tag must be within the head tag and it must be the first tag in the head tag. You can use only one base tag in a document and you must use the href attribute, target attribute or both.
 
Standard Syntax
 
<base
href="URL"
target="frame or window name | _blank | _parent | _self |_top">
 
Examples
  1. <!-- standard HTML syntax --->  
  2. <base href="http:// www.c-sharpcorner.com/">  
  3.     <base target="_blank" href="http:// www.c-sharpcorner.com/">  

Attributes Introduced by HTML5

 
Values Description
accesskey spaced list of accelerator key(s)
contenteditable true | false | inherit
contextmenu id of menu
data-X user-defined data
draggable true | false | auto
hidden hidden
itemid microdata id in URL format
itemprop microdata value
itemref space-separated list of IDs that may contain microdata
itemscope itemscope
itemtype microdata type in URL format
spellcheck true | false"
tabindex number
  
HTML5 Event Attributes
onabort onblur oncanplay oncanplaythrough onchange
onclick oncontextmenu ondblclick ondrag ondragend
ondragenter ondragleave ondragover ondragstart ondrop
ondurationchange onemptied onended onerror onfocus
onformchange onforminput oninput oninvalid onkeydown
onkeypress onkeypress onkeyup onload onloadeddata
onloadedmetadata onloadstart onmousedown onmousemove onmouseout
onmouseover onmouseup onmousewheel onpause onplay
onplaying onprogress onratechange onreadystatechange onscroll
onseeked onseeking onselect onshow onstalled
onsubmit onsuspend ontimeupdate onvolumechange onwaiting
 

Attributes Defined by Internet Explorer

 
id="unique alphanumeric identifier" (4)
 

Events Defined by Internet Explorer

 
onlayoutcomplete,
onmouseenter,
onmouseleave,
onreadystatechange
 
HTMLPage.htm
  1. <!DOCTYPE html>  
  2. <html>  
  3.     <head>  
  4.         <base href="http://www.c-sharpcorner.com/"/>  
  5.         <title></title>  
  6.     </head>  
  7.     <body>  
  8.         <header>  
  9.             <P>Hi... Freinds.  
  10.             </header>  
  11.             <p>I am using a base tag in this article. Before starting anything, I want to share something with you. I got  much knowledge of Asp.net from   
  12.                 <a href="/Articles/ArticleListing.aspx?SectionID=1&SubSectionID=75">csharpcorner</a> site. I am in touch with   
  13.                 <a href="">csharpcorner</a>from long time. You are definitely surprised that why I am sharing with you.Actually I got confuse that which example I should use to explain base tag. In this article i have applied base tag on   
  14.                 <a href="">csharpcorner</a> word that will navigate you to   
  15.                 <a href="">csharpcorner</a> website. When you click on   
  16.                 <a href="/UploadFile/667ddf/8187/">area tag</a> you will navigate to my article.  
  17.             </P>  
  18.         </body>  
  19.     </html>   
Output
 
Internet Explorer
 
Base Tag
 
Chrome
 
Base Tag
 
FireFox
 
Base Tag
 
Safari
 
Base Tag