The Document Base URL Element - HTML - MDN Web Docs - Mozilla
Có thể bạn quan tâm
- References
- HTML
- Elements
- <base>
- English (US)
- Remember language
- Deutsch
- Español
- Français
- 日本語
- 한국어
- Português (do Brasil)
- Русский
- 中文 (简体)
- 正體中文 (繁體)
- Attributes
- Usage notes
- Examples
- Technical summary
- Specifications
- Browser compatibility
- HTML
- Beginner's tutorials
- Your first website: Creating the content
- Structuring content with HTML
- Basic HTML syntax
- What's in the head? Webpage metadata
- Headings and paragraphs in HTML
- Emphasis and importance
- Lists
- Structuring documents
- Advanced text features
- Creating links
- Challenge: Marking up a letter
- Challenge: Structuring a page of content
- HTML images
- HTML video and audio
- Challenge: Mozilla splash page
- HTML table basics
- HTML table accessibility
- Challenge: Structuring a planet data table
- Forms and buttons in HTML
- Debugging HTML
- Guides
- Content categories
- Block-level elements
- Inline elements
- Quirks Mode and Standards Mode
- Date and time formats used in HTML
- Constraint validation
- Microdata
- Microformats
- Viewport meta tag
- Allowing cross-origin use of images and canvas
- References
- HTML elements
- <a>
- <abbr>
- <acronym> Deprecated
- <address>
- <area>
- <article>
- <aside>
- <audio>
- <b>
- <base>
- <bdi>
- <bdo>
- <big> Deprecated
- <blockquote>
- <body>
- <br>
- <button>
- <canvas>
- <caption>
- <center> Deprecated
- <cite>
- <code>
- <col>
- <colgroup>
- <data>
- <datalist>
- <dd>
- <del>
- <details>
- <dfn>
- <dialog>
- <dir> Deprecated
- <div>
- <dl>
- <dt>
- <em>
- <embed>
- <fencedframe> Experimental
- <fieldset>
- <figcaption>
- <figure>
- <font> Deprecated
- <footer>
- <form>
- <frame> Deprecated
- <frameset> Deprecated
- <h1>
- <head>
- <header>
- <hgroup>
- <hr>
- <html>
- <i>
- <iframe>
- <img>
- <input>
- <ins>
- <kbd>
- <label>
- <legend>
- <li>
- <link>
- <main>
- <map>
- <mark>
- <marquee> Deprecated
- <menu>
- <meta>
- <meter>
- <nav>
- <nobr> Deprecated
- <noembed> Deprecated
- <noframes> Deprecated
- <noscript>
- <object>
- <ol>
- <optgroup>
- <option>
- <output>
- <p>
- <param> Deprecated
- <picture>
- <plaintext> Deprecated
- <portal> Experimental
- <pre>
- <progress>
- <q>
- <rb> Deprecated
- <rp>
- <rt>
- <rtc> Deprecated
- <ruby>
- <s>
- <samp>
- <script>
- <search>
- <section>
- <select>
- <slot>
- <small>
- <source>
- <span>
- <strike> Deprecated
- <strong>
- <style>
- <sub>
- <summary>
- <sup>
- <table>
- <tbody>
- <td>
- <template>
- <textarea>
- <tfoot>
- <th>
- <thead>
- <time>
- <title>
- <tr>
- <track>
- <tt> Deprecated
- <u>
- <ul>
- <var>
- <video>
- <wbr>
- <xmp> Deprecated
- Global attributes
- accesskey
- anchor Experimental Non-standard
- autocapitalize
- autocorrect Experimental
- autofocus
- class
- contenteditable
- data-*
- dir
- draggable
- enterkeyhint
- exportparts
- hidden
- id
- inert
- inputmode
- is
- itemid
- itemprop
- itemref
- itemscope
- itemtype
- lang
- nonce
- part
- popover
- slot
- spellcheck
- style
- tabindex
- title
- translate
- virtualkeyboardpolicy Experimental
- writingsuggestions
- Attributes
- accept
- autocomplete
- capture
- crossorigin
- dirname
- disabled
- elementtiming
- for
- max
- maxlength
- min
- minlength
- multiple
- pattern
- placeholder
- readonly
- rel
- required
- size
- step
- <input> types
- <input type="button">
- <input type="checkbox">
- <input type="color">
- <input type="date">
- <input type="datetime-local">
- <input type="email">
- <input type="file">
- <input type="hidden">
- <input type="image">
- <input type="month">
- <input type="number">
- <input type="password">
- <input type="radio">
- <input type="range">
- <input type="reset">
- <input type="search">
- <input type="submit">
- <input type="tel">
- <input type="text">
- <input type="time">
- <input type="url">
- <input type="week">
- Attributes
- Usage notes
- Examples
- Technical summary
- Specifications
- Browser compatibility
The <base> HTML element specifies the base URL to use for all relative 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 with Node.baseURI. If the document has no <base> elements, then baseURI defaults to location.href.
Attributes
This element's attributes include the global attributes.
Warning: A <base> element must have an href attribute, a target attribute, or both. If at least one of these attributes are specified, the <base> element must come before other elements with attribute values that are URLs, such as a <link>'s href attribute.
hrefThe base URL to be used throughout the document for relative URLs. Absolute and relative URLs are allowed. data: and javascript: URLs are not allowed.
targetA keyword or author-defined name of the default browsing context to show the results of navigation from <a>, <area>, or <form> elements without explicit target 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 first href and first target 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 to https://example.com/#anchor.
target may not contain ASCII newline, tab, or <
If the target 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 unclosed target 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 target="_blank" /> <base target="_top" href="https://example.com/" />Technical summary
Content categories | Metadata content. |
---|---|
Permitted content | None; it is a void element. |
Tag omission | Must have a start tag and must not have an end tag. |
Permitted parents | A <head> that doesn't contain another <base> element. |
Implicit ARIA role | No corresponding role |
Permitted ARIA roles | No role permitted |
DOM interface | HTMLBaseElement |
Specifications
Specification |
---|
HTML Standard # the-base-element |
Browser compatibility
BCD tables only load in the browser
Help improve MDN
Was this page helpful to you?YesNoLearn how to contribute.This page was last modified on Aug 27, 2024 by MDN contributors.
View this page on GitHub • Report a problem with this contentTừ khóa » Html Original Website
-
W3C HTML
-
HTML - Wikipedia
-
How To Build A Website With HTML | DigitalOcean
-
HTML Tutorial - W3Schools
-
The World Wide Web Project - CERN
-
CERN
-
Living Standard - HTML
-
HTML Standard
-
HTML Full Course - Build A Website Tutorial - YouTube
-
Bootstrap · The Most Popular HTML, CSS, And JS Library In The World.
-
Webmasters - Sharing - Facebook For Developers
-
Webflow: Create A Custom Website | No-code Website Builder
-
WordPress Themes & Website Templates From ThemeForest