Qortora · Search · Indexed page

html.spec.whatwg.orgFetched 2026-09-01T06:50:17Z

HTML Standard

HTML Standard 4 The elements of HTML4.1 The document element4.1.1 The html element4.2 Document metadata4.2.1 The head element4.2.2 The title element4.2.3 The base element4.2.4 The link element4.2.4.1 Processing the media attribute4.2.4.2 Processing the type attribute4.2.4.3 Fetch…

Open original source · Full cached text

HTML Standard 4 The elements of HTML4.1 The document element4.1.1 The html element4.2 Document metadata4.2.1 The head element4.2.2 The title element4.2.3 The base element4.2.4 The link element4.2.4.1 Processing the media attribute4.2.4.2 Processing the type attribute4.2.4.3 Fetching and processing a resource from a link element4.2.4.4 Processing `Link` headers4.2.4.5 Early hints4.2.4.6 Providing users with a means to follow hyperlinks created using the link element4.2.5 The meta element4.2.5.1 Standard metadata names4.2.5.2 Other metadata names4.2.5.3 Pragma directives4.2.5.4 Specifying the document's character encoding4.2.6 The style element4.2.7 Interactions of styling and scripting4 The elements of HTML 4.1 The document element 4.1.1 The html element ✔MDN HTML element represents the root (top-level element) of an HTML document, so it is also referred to as the root element. All other elements must be descendants of this element.">Element/htmlSupport in all current engines.Firefox1+Safari1+Chrome1+ Opera12.1+Edge79+ Edge (Legacy)12+Internet ExplorerYes Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android12.1+ ✔MDNHTMLHtmlElementSupport in all current engines.Firefox1+Safari1+Chrome1+ Opera12.1+Edge79+ Edge (Legacy)12+Internet Explorer5.5+ Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android12.1+ Categories:None.Contexts in which this element can be used:As document's document element.Wherever a subdocument fragment is allowed in a compound document.Content model:A head element followed by a body element.Tag omission in text/html:An html element's start tag can be omitted if the first thing inside the html element is not a comment.An html element's end tag can be omitted if the html element is not immediately followed by a comment.Content attributes:Global attributesAccessibility considerations:For authors.For implementers.Sanitization:Default.DOM interface: [Exposed=Window] interface HTMLHtmlElement : HTMLElement { [HTMLConstructor] constructor(); // also has obsolete members }; The html element represents the root of an HTML document. Authors are encouraged to specify a lang attribute on the root html element, giving the document's language. This aids speech synthesis tools to determine what pronunciations to use, translation tools to determine what rules to use, and so forth. The html element in the following example declares that the document's language is English. <!DOCTYPE html> <html lang="en"> <head> <title>Swapping Songs</title> </head> <body> <h1>Swapping Songs</h1> <p>Tonight I swapped some of the songs I wrote with some friends, who gave me some of the songs they wrote. I love sharing my music.</p> </body> </html> 4.2 Document metadata 4.2.1 The head element ✔MDN HTML element contains machine-readable information (metadata) about the document, like its title, scripts, and style sheets.">Element/headSupport in all current engines.Firefox1+Safari1+Chrome1+ Opera?Edge79+ Edge (Legacy)12+Internet ExplorerYes Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android? ✔MDNHTMLHeadElementSupport in all current engines.Firefox1+Safari1+Chrome1+ Opera12.1+Edge79+ Edge (Legacy)12+Internet Explorer5.5+ Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android12.1+ Categories:None.Contexts in which this element can be used:As the first element in an html element.Content model:If the document is an iframe srcdoc document or if title information is available from a higher-level protocol: Zero or more elements of metadata content, of which no more than one is a title element and no more than one is a base element.Otherwise: One or more elements of metadata content, of which exactly one is a title element and no more than one is a base element.Tag omission in text/html:A head element's start tag can be omitted if the element is empty, or if the first thing inside the head element is an element.A head element's end tag can be omitted if the head element is not immediately followed by ASCII whitespace or a comment.Content attributes:Global attributesAccessibility considerations:For authors.For implementers.Sanitization:Default.DOM interface: [Exposed=Window] interface HTMLHeadElement : HTMLElement { [HTMLConstructor] constructor(); }; The head element represents a collection of metadata for the Document. The collection of metadata in a head element can be large or small. Here is an example of a very short one: <!doctype html> <html lang=en> <head> <title>A document with a short head</title> </head> <body> ... Here is an example of a longer one: <!DOCTYPE HTML> <HTML LANG="EN"> <HEAD> <META CHARSET="UTF-8"> <BASE HREF="https://www.example.com/"> <TITLE>An application with a long head</TITLE> <LINK REL="STYLESHEET" HREF="default.css"> <LINK REL="STYLESHEET ALTERNATE" HREF="big.css" TITLE="Big Text"> <SCRIPT SRC="support.js"></SCRIPT> <META NAME="APPLICATION-NAME" CONTENT="Long headed application"> </HEAD> <BODY> ... The title element is a required child in most situations, but when a higher-level protocol provides title information, e.g., in the subject line of an email when HTML is used as an email authoring format, the title element can be omitted. 4.2.2 The title element ✔MDN HTML element defines the document's title that is shown in a browser's title bar or a page's tab. It only contains text; tags within the element are ignored.">Element/titleSupport in all current engines.Firefox1+Safari1+Chrome1+ Opera?Edge79+ Edge (Legacy)12+Internet Explorer1+ Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android? ✔MDN. This element inherits all of the properties and methods of the HTMLElement interface.">HTMLTitleElementSupport in all current engines.Firefox1+Safari3+Chrome1+ Opera12.1+Edge79+ Edge (Legacy)12+Internet Explorer5.5+ Firefox Android?Safari iOS1+Chrome Android?WebView Android?Samsung Internet?Opera Android12.1+ Categories:Metadata content.Contexts in which this element can be used:In a head element containing no other title elements.Content model:Text that is not inter-element whitespace.Tag omission in text/html:Neither tag is omissible.Content attributes:Global attributesAccessibility considerations:For authors.For implementers.Sanitization:Default.DOM interface: [Exposed=Window] interface HTMLTitleElement : HTMLElement { [HTMLConstructor] constructor(); [CEReactions] attribute DOMString text; }; The title element represents the document's title or name. Authors should use titles that identify their documents even when they are used out of context, for example in a user's history or bookmarks, or in search results. The document's title is often different from its first heading, since the first heading does not have to stand alone when taken out of context. There must be no more than one title element per document. If it's reasonable for the Document to have no title, then the title element is probably not required. See the head element's content model for a description of when the element is required. title.text [ = value ] Returns the child text content of the element. Can be set, to replace the element's children with the given value. The text attribute's getter must return this title element's child text content. The text attribute's setter must string replace all with the given value within this title element. Here are some examples of appropriate titles, contrasted with the top-level headings that might be used on those same pages. <title>Introduction to The Mating Rituals of Bees</title> ... <h1>Introduction</h1> <p>This companion guide to the highly successful <cite>Introduction to Medieval Bee-Keeping</cite> book is... The next page might be a part of the same site. Note how the title describes the subject matter unambiguously, while the first heading assumes the reader knows what the context is and therefore won't wonder if the dances are Salsa or Waltz: <title>Dances used during bee mating rituals</title> ... <h1>The Dances</h1> The string to use as the document's title is given by the document.title IDL attribute. User agents should use the document's title when referring to the document in their user interface. When the contents of a title element are used in this way, the directionality of that title element should be used to set the directionality of the document's title in the user interface. 4.2.3 The base element ✔MDN HTML element specifies the base URL to use for all relative URLs in a document. There can be only one element in a document.">Element/baseSupport in all current engines.Firefox1+Safari3+Chrome1+ Opera?Edge79+ Edge (Legacy)12+Internet ExplorerYes Firefox Android?Safari iOS?Chrome Android?WebView Android?Samsung Internet?Opera Android? ✔MDNHTMLBaseElementSupport in all current engines.Firefox1+Safari3+Chrome1+ Opera12.1+Edge79+ Edge (Legacy)12+Internet Explorer5.5+ Firefox Android?Safari iOS1+Chrome Android?WebView Android?Samsung Internet?Opera Android12.1+ Categories:Metadata content.Contexts in which this element can be used:In a head element containing no other base elements.Content model:Nothing.Tag omission in text/html:No end tag.Content attributes:Global attributeshref — Document base URL target — Default navigable for hyperlink navigation and form submission Accessibility considerations:For authors.For implementers.Sanitization:Unsafe.DOM interface: [Exposed=Window] interface HTMLBaseElement : HTMLElement { [HTMLConstructor] constructor(); [CEReactions, ReflectSetter] attribute USVString href; [CEReactions, Reflect] attribute DOMString target; }; The base element allows authors to specify the document base URL for the purposes of parsing URLs, and the name of the default navigable for the purposes of following hyperlinks. The element does not represent any content beyond this information. There must be no more than one base element per document. A base element must have either an href attribute, a target attribute, or both. The href content attribute, if specified, must contain a valid URL potentially surrounded by spaces. A base element, if it has an href attribute, must come before any other elements in the tree that have attributes defined as taking URLs. If there are multiple base elements with href attributes, all but the first are ignored. The target attribute, if specified, must contain a valid navigable target name or keyword, which specifies which navigable is to be used as the default when hyperlinks and forms in the Document cause navigation. A base element, if it has a target attribute, must come before any elements in the tree that represent hyperlinks. If there are multiple base elements with target attributes, all but the first are ignored. To get an element's target, given an a, area, or form element element, and an optional string-or-null target (default null), run these steps: If target is null: If element has a target attribute, then set target to that attribute's value.Otherwise, if element's node document contains a base element with a target attribute, set target to the value of the target attribute of the first such base element. If target is not null, and contains an ASCII tab or newline and a U+003C (<), then set target to "_blank".Return target. A base element that is the first base element with an href content attribute in a document tree has a frozen base URL. The frozen base URL must be immediately set for an element whenever any of the following situations occur: The base element becomes the first base element in tree order with an href content attribute in its Document.The base element is the first base element in tree order with an href content attribute in its Document, and its href content attribute is changed. To set the frozen base URL for an element element: Let document be element's node document. Let urlRecord be the result of parsing the value of element's href content attribute with document's fallback bas…