HTML Tag: “Base”

The HTML Base Element (<base>) specifies the base URL to use for all relative URLs contained within a document. There can be only one <base> element in a document.

Base element is define in a head section

its syntax is

<head>
<base href=” Base URL“>
</head>

Example

<head>
<base href=”http://www.example.com/page.html”&gt;
<base target=”_blank” href=”http://www.example.com/page.html”&gt;
</head>

Attribute

      • href

The base URL to be used throughout the document for relative URL addresses. If this attribute is specified, this element must come before any other elements with attributes whose values are URLs.
Absolute and relative URIs are allowed (but see note section below).

      • target

A name or keyword indicating the default location to display the result when hyperlinks or forms cause navigation, for elements that do not have an explicit target reference. In HTML4, this is the name of, or a keyword for, a frame. In HTML5, it is a name of, or keyword for, a browsing context (for example, tab, window, or inline frame). The following keywords have special meanings:

      • _self: Load the result into the same HTML4 frame (or HTML5 browsing context) as the current one. This value is the default if the attribute is not specified.
      • _blank: Load the result into a new unnamed HTML4 window or HTML5 browsing context.
      • _parent: Load the result into the HTML4 frameset parent of the current frame or HTML5 parent browsing context of the current one. If there is no parent, this option behaves the same way as _self.
      • _top: In HTML4: Load the result into the full, original window, canceling all other frames. In HTML5: Load the result into the top-level browsing context (that is, the browsing context that is an ancestor of the current one, and has no parent). If there is no parent, this option behaves the same way as _self.

I have made a small Example. Check it Hope you understand well. 🙂

Advertisements

Application cache using HTML5

HTML5 provides an application caching mechanism that lets web-based applications run offline. Developers can use the Application Cache (AppCache) interface to specify resources that the browser should cache and make available to offline users. Applications that are cached load and work correctly even if users click the refresh button when they are offline.

Using an application cache gives an application the following benefits:

  • Offline browsing: users can navigate a site even when they are offline.
  • Speed: cached resources are local, and therefore load faster.
  • Reduced server load: the browser only downloads resources that have changed from the server.

How?

To enable application cache you must include manifest attribute in <html> tag

<html manifest=”example.appcache”>

</html>

The manifest attribute references a cache manifest file, which is a text file that lists resources (files) that the browser should cache for your application.

You should include the manifest attribute on every page of your application that you want cached. The browser does not cache pages that do not contain the manifest attribute, unless such pages are explicitly listed in the manifest file itself. You do not need to list all the pages you want cached in the manifest file, the browser implicitly adds every page that the user visits and that has the manifest attribute set to the application cache.