base href='' - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:base

Introduction

The href attribute sets the base URL against which relative URLs in the rest of the document will be resolved.

Using the href Attribute in the base Element

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
   <head> 
      <base href="http://java2s.com/"> 
   </head> 
   <body> 
      <p>
          I like 
         <code id="myId">HTML</code>
          and CSS. <!-- ww w  . j  a va2  s .  c  o m-->
      </p> 
      <a href="index.htm">Visit java2s.com</a> 
      <a href="page2.html">Page 2</a>  
       both index.htm and page2.html will be resolved to http://java2s.com/index.htm and http://java2s.com/page.html, respectively.
   </body>
</html>

Related Tutorials