Setting the Base for Relative URLs
The base element sets a base URL.
It is then used with relative links in the HTML document. A relative link omits the protocol, host, and port parts of the URL. A relative URL is valuated against by either the base element or the URL used to load the document. An HTML document should contain at most one base element.
The href attribute specifies the base URL.
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
<base href="http://yourServer/listings/" />
</head>
<body>
<p>
I like <code>HTML</code> and CSS.
</p>
<a href="http://java2s.com">Visit java2s.com</a>
<a href="page2.html">Page 2</a>
</body>
</html>
The target attribute tells the browser how to open URLs. The values you specify for this attribute represent a browsing context.
Home
HTML CSS Book
HTML
HTML CSS Book
HTML
Document Structure:
- The doctype Element
- The html Element
- The head Element
- The body Element
- Setting the Document Title
- Setting the Base for Relative URLs
- Specifying Name/Value Metadata Pairs
- Declaring a Character Encoding
- Simulate an HTTP Header
- Defining CSS Styles
- Specifying the Media for a Style
- Denoting External Resources
- Defining a Favicon for Your Page
- Using the Scripting Elements
- Loading an External Scripting Library
- Deferring Execution of a Script
- Executing a Script Asynchronously
- The noscript Element
- Redirect the user to a different URL if it doesn't support JavaScript.
Related: