A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/html/elements/base below:

base · WebPlatform Docs

base Summary

The base element is used to specify a document’s base URL and base target that is used for resolving URI references (relative URLs) within the document.

Overview Table
DOM Interface
HTMLBaseElement
Permitted contents *none* Permitted parents Only permitted to occur once within [``](/html/elements/head).

A relative URL (

some/example.html

) needs to be transformed to a fully qualified URL (

) before it can be downloaded. Usually the document's URL (available to JavaScript through the [`location`](/dom/Location) object) is used as the base URL for resolving relative URLs. The `

` element allows you to override this default with the [`href`](/html/attributes/href) attribute.

Links (<a>) and forms (<form>) open in a (target). The default target is _self, resulting in the link opening in the same window as the document currently viewed. This default can be overridden document-wide using <base target="…">.

If a document is integrated in an iframe, it may help to specify <base target="_parent"> in order to open the links within the iframe in the scope parent document. If _parent or _top are used without the document really being integrated in an hierarchy, expect the behavior of _self.

HTML Attributes Examples

The example shows a link with the relative destination some-file.html that gets rewritten to http://example.org/deep/some-file.html

<!DOCTYPE html>
<html>
  <head>
    <title>base element example</title>
    <base href="http://www.example.org/deep/">
  </head>
  <body>
    <p>A <a href="some-file.html">relative link</a>.</p>
    
    <p>A <a href="http://www.example.org/deep/some-file.html">relative link</a>.</p>
  </body>
</html>

The example shows that base only affects elements following it

<head>
  <title>base element example</title>
  <link href="my-style.css" rel="stylesheet">
  <base href="http://example.com">
  <link href="my-other-style.css" rel="stylesheet">
  
</head>

The example shows how multiple base occurrences are collapsed and ignored

<head>
  <title>base element example</title>
  <base href="http://example.com">
  <base target="_blank">
  <base href="http://webplatform.org" target="_top">
  
</head>
Notes

Note Inline SVGs using references like fill="url(#element-id)" can be a problem in documents using <base>. The reason is that url(#element-id) is actually a URL, not a CSS selector. At least Firefox and Chrome are susceptible to this behavior.

Related specifications
HTML 5.1
W3C Working Draft
HTML 5
W3C Recommendation
HTML 4.01
W3C Recommendation
See also External resources

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4