Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

<base>: The Document Base URL element

BaselineWidely available *

The<base>HTML element specifies the base URL to use for allrelative URLs in a document. There can be only one<base> element in a document.

A document's used base URL can be accessed by scripts withNode.baseURI. If the document has no<base> elements, thenbaseURI defaults tolocation.href.

Attributes

This element's attributes include theglobal attributes.

Warning:A<base> element must have anhref attribute, atarget attribute, or both.If at least one of these attributes are specified, the<base> elementmust come before other elements with attribute values that are URLs, such as a<link>'shref attribute.

href

The base URL to be used throughout the document for relative URLs.Absolute and relative URLs are allowed.data: and#"#target">target

Akeyword orauthor-defined name of the defaultbrowsing context to show the results of navigation from<a>,<area>, or<form> elements without explicittarget attributes. The following keywords have special meanings:

  • _self (default): Show the result in the current browsing context.
  • _blank: Show the result in a new, unnamed browsing context.
  • _parent: Show the result in the parent browsing context of the current one, if the current page is inside a frame. If there is no parent, acts the same as_self.
  • _top: Show the result in the topmost browsing context (the browsing context that is an ancestor of the current one and has no parent). If there is no parent, acts the same as_self.

Usage notes

Multiple <base> elements

If multiple<base> elements are used, only the firsthref and firsttarget are obeyed — all others are ignored.

In-page anchors

Links pointing to a fragment in the document — e.g.,<a href="#some-id"> — are resolved with the<base>, triggering an HTTP request to the base URL with the fragment attached.

For example, given<base href="https://example.com/"> and this link:<a href="#anchor">To anchor</a>. The link points tohttps://example.com/#anchor.

target may not contain ASCII newline, tab, or <

If thetarget attribute contains an ASCII newline, tab, or the< character, the value is reset to_blank.This is to prevent dangling markup injection attacks, a script-less attack in which an unclosedtarget attribute is injected into the page so that any text that follows is captured until the browser reaches a character that closes the attribute.

Open Graph

Open Graph tags do not acknowledge<base>, and should always have full absolute URLs. For example:

html
<meta property="og:image" content="https://example.com/thumbnail.jpg" />

Examples

html
<base href="https://www.example.com/" /><base /><base href="https://example.com/" />

Technical summary

Content categoriesMetadata content.
Permitted contentNone; it is avoid element.
Tag omissionMust have a start tag and must not have an end tag.
Permitted parents A<head> that doesn't contain another<base> element.
Implicit ARIA roleNo corresponding role
Permitted ARIA rolesNorole permitted
DOM interfaceHTMLBaseElement

Specifications

Specification
HTML
# the-base-element

Browser compatibility


[8]ページ先頭

©2009-2025 Movatter.jp