1.仕様
HEAD要素
は、
文書のメタデータの
集まりを表します。
- head
-
文書に関する付加的な情報 (a collection of metadata for the Document.)
- 種類
-
通常要素
- カテゴリ
-
なし
- 使用できるコンテキスト
-
html
要素 の最初html
要素 の最初のコンテンツとして、使用できます。 - コンテンツモデル
-
1つ以上のメタデータ
コンテンツ 1つ以上のメタデータ
コンテンツ が配置できます。メタデータ
コンテンツ に分類される要素は、meta要素 , title要素 , base要素 , link要素 , style要素 , script要素 , noscript要素 , template要素 です。head (title&base?&meta*&link*&style*&script*&noscript*&template*)
ドキュメントが iframe srcdoc ドキュメントである場合、またはタイトル情報が上位レベルのプロトコルから利用できる場合は、メタデータコンテンツの 0 個以上の要素を設定できます。そのうちの 1 つだけがtitle要素で、1 つだけがbase要素です。
それ以外の場合は、メタデータコンテンツの 1 つ以上の要素。そのうちの 1 つだけがtitle要素であり、base要素は 1 つだけです。
- タグの省略
-
どちらのタグも省略できます。
開始タグは、要素が空の場合は省略してもよいし、head要素の内部の最初のものが要素なら省略可能です。
終了タグは、head要素に続く最初のものが空白文字やコメントでない場合は省略可能です。
- コンテンツ属性
-
グローバル属性のみ
profile属性がありましたが、廃止されました。不要です。完全に省いてください。
- DOM インターフェイス
-
HTMLHeadElement
[Exposed=Window]
interface HTMLHeadElement : HTMLElement {
[HTMLConstructor] constructor();
};
HTMLElement
[Exposed=Window]
interface HTMLElement : Element {
[HTMLConstructor] constructor();
// metadata attributes
[CEReactions] attribute DOMString title;
[CEReactions] attribute DOMString lang;
[CEReactions] attribute boolean translate;
[CEReactions] attribute DOMString dir;
// user interaction
[CEReactions] attribute (boolean or unrestricted double or DOMString)? hidden;
[CEReactions] attribute DOMString inert;
undefined click();
[CEReactions] attribute DOMString accessKey;
readonly attribute DOMString accessKeyLabel;
[CEReactions] attribute boolean draggable;
[CEReactions] attribute boolean spellcheck;
[CEReactions] attribute DOMString writingSuggestions;
[CEReactions] attribute DOMString autocapitalize;
[CEReactions] attribute [LegacyNullToEmptyString] DOMString innerText;
[CEReactions] attribute [LegacyNullToEmptyString] DOMString outerText;
ElementInternals attachInternals();
// The popover API
undefined showPopover();
undefined hidePopover();
boolean togglePopover(optional boolean force);
[CEReactions] attribute DOMString? popover;
};
HTMLElement includes GlobalEventHandlers;
HTMLElement includes ElementContentEditable;
HTMLElement includes HTMLOrSVGElement;
Element
[Exposed=Window]
interface Element : Node {
readonly attribute DOMString? namespaceURI;
readonly attribute DOMString? prefix;
readonly attribute DOMString localName;
readonly attribute DOMString tagName;
[CEReactions] attribute DOMString id;
[CEReactions] attribute DOMString className;
[SameObject, PutForwards=value] readonly attribute DOMTokenList classList;
[CEReactions, Unscopable] attribute DOMString slot;
boolean hasAttributes();
[SameObject] readonly attribute NamedNodeMap attributes;
sequence<DOMString> getAttributeNames();
DOMString? getAttribute(DOMString qualifiedName);
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
[CEReactions] undefined setAttribute(DOMString qualifiedName, DOMString value);
[CEReactions] undefined setAttributeNS(DOMString? namespace, DOMString qualifiedName, DOMString value);
[CEReactions] undefined removeAttribute(DOMString qualifiedName);
[CEReactions] undefined removeAttributeNS(DOMString? namespace, DOMString localName);
[CEReactions] boolean toggleAttribute(DOMString qualifiedName, optional boolean force);
boolean hasAttribute(DOMString qualifiedName);
boolean hasAttributeNS(DOMString? namespace, DOMString localName);
Attr? getAttributeNode(DOMString qualifiedName);
Attr? getAttributeNodeNS(DOMString? namespace, DOMString localName);
[CEReactions] Attr? setAttributeNode(Attr attr);
[CEReactions] Attr? setAttributeNodeNS(Attr attr);
[CEReactions] Attr removeAttributeNode(Attr attr);
ShadowRoot attachShadow(ShadowRootInit init);
readonly attribute ShadowRoot? shadowRoot;
Element? closest(DOMString selectors);
boolean matches(DOMString selectors);
boolean webkitMatchesSelector(DOMString selectors); // legacy alias of .matches
HTMLCollection getElementsByTagName(DOMString qualifiedName);
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
HTMLCollection getElementsByClassName(DOMString classNames);
[CEReactions] Element? insertAdjacentElement(DOMString where, Element element); // legacy
undefined insertAdjacentText(DOMString where, DOMString data); // legacy
};
GlobalEventHandlers
interface mixin GlobalEventHandlers {
attribute EventHandler onabort;
attribute EventHandler onauxclick;
attribute EventHandler onbeforeinput;
attribute EventHandler onbeforematch;
attribute EventHandler onbeforetoggle;
attribute EventHandler onblur;
attribute EventHandler oncancel;
attribute EventHandler oncanplay;
attribute EventHandler oncanplaythrough;
attribute EventHandler onchange;
attribute EventHandler onclick;
attribute EventHandler onclose;
attribute EventHandler oncontextlost;
attribute EventHandler oncontextmenu;
attribute EventHandler oncontextrestored;
attribute EventHandler oncopy;
attribute EventHandler oncuechange;
attribute EventHandler oncut;
attribute EventHandler ondblclick;
attribute EventHandler ondrag;
attribute EventHandler ondragend;
attribute EventHandler ondragenter;
attribute EventHandler ondragleave;
attribute EventHandler ondragover;
attribute EventHandler ondragstart;
attribute EventHandler ondrop;
attribute EventHandler ondurationchange;
attribute EventHandler onemptied;
attribute EventHandler onended;
attribute OnErrorEventHandler onerror;
attribute EventHandler onfocus;
attribute EventHandler onformdata;
attribute EventHandler oninput;
attribute EventHandler oninvalid;
attribute EventHandler onkeydown;
attribute EventHandler onkeypress;
attribute EventHandler onkeyup;
attribute EventHandler onload;
attribute EventHandler onloadeddata;
attribute EventHandler onloadedmetadata;
attribute EventHandler onloadstart;
attribute EventHandler onmousedown;
[LegacyLenientThis] attribute EventHandler onmouseenter;
[LegacyLenientThis] attribute EventHandler onmouseleave;
attribute EventHandler onmousemove;
attribute EventHandler onmouseout;
attribute EventHandler onmouseover;
attribute EventHandler onmouseup;
attribute EventHandler onpaste;
attribute EventHandler onpause;
attribute EventHandler onplay;
attribute EventHandler onplaying;
attribute EventHandler onprogress;
attribute EventHandler onratechange;
attribute EventHandler onreset;
attribute EventHandler onresize;
attribute EventHandler onscroll;
attribute EventHandler onscrollend;
attribute EventHandler onsecuritypolicyviolation;
attribute EventHandler onseeked;
attribute EventHandler onseeking;
attribute EventHandler onselect;
attribute EventHandler onslotchange;
attribute EventHandler onstalled;
attribute EventHandler onsubmit;
attribute EventHandler onsuspend;
attribute EventHandler ontimeupdate;
attribute EventHandler ontoggle;
attribute EventHandler onvolumechange;
attribute EventHandler onwaiting;
attribute EventHandler onwebkitanimationend;
attribute EventHandler onwebkitanimationiteration;
attribute EventHandler onwebkitanimationstart;
attribute EventHandler onwebkittransitionend;
attribute EventHandler onwheel;
};
ElementContentEditable
interface mixin ElementContentEditable {
[CEReactions] attribute DOMString contentEditable;
[CEReactions] attribute DOMString enterKeyHint;
readonly attribute boolean isContentEditable;
[CEReactions] attribute DOMString inputMode;
};
HTMLOrSVGElement
interface mixin HTMLOrSVGElement {
[SameObject] readonly attribute DOMStringMap dataset;
attribute DOMString nonce; // intentionally no [CEReactions]
[CEReactions] attribute boolean autofocus;
[CEReactions] attribute long tabIndex;
undefined focus(optional FocusOptions options = {});
undefined blur();
};
- ARIA in HTML
-
暗黙的="
No
" ARIAロール="No
" aria-* 属性="No
"暗黙的な ARIAセマンティクスがありませんが、意味はあり、この意味は、ARIA によって提供されず、ARIA のユーザーに公開されていないロール、状態、プロパティで表現される可能性があります。
作成者は、暗黙的な ARIAセマンティクス, または HTML要素のネイティブセマンティクスを上書きしてはいけません。
記述できる aria-* 属性はありません。
- レンダリング
- ボックスを生成しない
非表示の要素
head {
display: none;
}
CSS を大雑把に読むと、 要素とその子孫はボックスやテキストシーケンスを生成しません。 などになります。
- 説明
-
head
要素 は、文書のメタデータの集まりを表します。head
要素 は、文書に関する機械可読な情報を、含む (囲む, まとめる) 要素です。<!DOCTYPE html>
<html lang=
"ja"> <head>
<meta charset=
"utf-8"> <title>head要素の例 - (Example of head element) | 離珠のHTMLでしぃ!</title>
</head>
<body>
<h1>head要素の例</h1>
<p>この例の head要素は、文書の付加的な情報の集まりを表しています。</p>
</body>
</html>
このサンプルへのリンクです。
(./exhead.htm) - 参照元
-
参照元
- HTML Living Standard. 4.2.1 The head element (Last Updated 27 August 2024)
- HTML Living Standard. 15 Rendering 15.3.1 Hidden elements (Last Updated 27 August 2024)
- HTML 5.2 W3C 勧告. 4.2.1. The head element (W3C勧告、2017年12月14日)
- HTML 5.2 W3C 勧告. 10.3.1. Hidden elements (W3C勧告、2017年12月14日)
- HTML 5.1 W3C 勧告. 4.2.1. The head element (W3C勧告、2016年11月1日)
- HTML 5.1 W3C 勧告. 10.3.1. Hidden elements (W3C勧告、2016年11月1日)
- HTML 5 W3C 勧告. 4.2.1 The head element (W3C勧告、2014年10月28日)
- HTML 5 W3C 勧告. 10.3.1. Hidden elements (W3C勧告、2014年10月28日)
- HTML 4.01 Specification W3C 勧告. 7.4.1 The HEAD element (W3C勧告1999年12月24日)
- HTML 3.2 Reference Specification. The HEAD element (W3C勧告1997年1月14日)
- Hypertext Markup Language - 2.0 (November 1995)
- Hypertext Markup Language (HTML) (June 1993)
- MDN Web Docs. HTML <head>: 文書メタデータ (ヘッダー) 要素
- JSONデータ
-
JSON形式での、データのイメージです。
{
"head": {
"check": "2024-09-01",
"group": "Page",
"element": "O O (TITLE & BASE?) +(META|LINK|STYLE|SCRIPT|NOSCRIPT|TEMPLATE) -- a collection of metadata for the Document. (Normal elements.) [None] --",
"attlist": {"%Global;": ""},
"comment": "文書に関する付加的な情報 (a collection of metadata for the Document.)",
"point": "文書のメタデータの集まりを表します。",
"description": "文書に関する機械可読な情報を、含む (囲む, まとめる) 要素です。",
"kind": "Normal",
"categories": "None",
"used": "HTML (HEAD,BODY)",
"contentmodel": "HEAD (%Metadata)+",
"contentmodelsupplement": [
"head (title&base?&meta*&link*&style*&script*&noscript*&template*)",
"ドキュメントが iframe srcdoc ドキュメントである場合、またはタイトル情報が上位レベルのプロトコルから利用できる場合は、メタデータコンテンツの 0 個以上の要素を設定できます。そのうちの 1 つだけがtitle要素で、1 つだけがbase要素です。",
"それ以外の場合は、メタデータコンテンツの 1 つ以上の要素。そのうちの 1 つだけがtitle要素であり、base要素は 1 つだけです。",
],
"tag": [
"O",
"O",
],
"tagsupplement": [
"開始タグは、要素が空の場合は省略してもよいし、head要素の内部の最初のものが要素なら省略可能です。",
"終了タグは、head要素に続く最初のものが空白文字やコメントでない場合は省略可能です。",
],
"attributes": "Global",
"attributessupplement": [
"profile属性がありましたが、廃止されました。不要です。完全に省いてください。",
],
"dominterface": "HTMLHeadElement",
"rendering": "Hidden",
"reference": [
{
"title": "HTML Living Standard. 4.2.1 The head element.",
"href": "https://html.spec.whatwg.org/multipage/semantics.html#the-head-element",
"heading": "HTML Living Standard. 4.2.1 The head element",
"sub": "Last Updated 27 August 2024",
},
{
"title": "HTML Living Standard. 15 Rendering 15.3.1 Hidden elements.",
"href": "https://html.spec.whatwg.org/multipage/rendering.htmll#hidden-elements",
"heading": "HTML Living Standard. 15 Rendering 15.3.1 Hidden elements",
"sub": "Last Updated 27 August 2024",
},
{
"title": "HTML 5.2 W3C Recommendation. 4.2.1. The head element.",
"href": "https://www.w3.org/TR/2017/REC-html52-20171214/document-metadata.html#the-head-element",
"heading": "HTML 5.2 W3C 勧告. 4.2.1. The head element",
"sub": "W3C勧告、2017年12月14日",
},
{
"title": "HTML 5.2 W3C Recommendation. 10.3.1. Hidden elements.",
"href": "https://www.w3.org/TR/2017/REC-html52-20171214/rendering.html#hidden-elements",
"heading": "HTML 5.2 W3C 勧告. 10.3.1. Hidden elements",
"sub": "W3C勧告、2017年12月14日",
},
{
"title": "HTML 5.1 W3C Recommendation. 4.2.1. The head element. W3C Recommendation, 1 November 2016.",
"href": "https://www.w3.org/TR/2016/REC-html51-20161101/document-metadata.html#the-head-element",
"heading": "HTML 5.1 W3C 勧告. 4.2.1. The head element",
"sub": "W3C勧告、2016年11月1日",
},
{
"title": "HTML 5.1 W3C Recommendation. 10.3.1. Hidden elements. W3C Recommendation, 1 November 2016.",
"href": "https://www.w3.org/TR/2016/REC-html51-20161101/rendering.html#hidden-elements",
"heading": "HTML 5.1 W3C 勧告. 10.3.1. Hidden elements",
"sub": "W3C勧告、2016年11月1日",
},
{
"title": "HTML 5 W3C Recommendation. 4.2.1 The head element. W3C Recommendation, 28 October 2014.",
"href": "https://www.w3.org/TR/2014/REC-html5-20141028/document-metadata.html#the-head-element",
"heading": "HTML 5 W3C 勧告. 4.2.1 The head element",
"sub": "W3C勧告、2014年10月28日",
},
{
"title": "HTML 5 W3C Recommendation. 10.3.1. Hidden elements. W3C Recommendation, 28 October 2014.",
"href": "https://www.w3.org/TR/2014/REC-html5-20141028/rendering.html#hidden-elements",
"heading": "HTML 5 W3C 勧告. 10.3.1. Hidden elements",
"sub": "W3C勧告、2014年10月28日",
},
{
"title": "HTML 4.01 Specification W3C Recommendation. 7.4.1 The HEAD element.",
"href": "https://www.w3.org/TR/html401/struct/global.html#h-7.4.1",
"heading": "HTML 4.01 Specification W3C 勧告. 7.4.1 The HEAD element",
"sub": "W3C勧告1999年12月24日",
},
{
"title": "HTML 3.2 Reference Specification. The HEAD element. W3C Recommendation 14-Jan-1997.",
"href": "https://www.w3.org/TR/2018/SPSD-html32-20180315/#head",
"heading": "HTML 3.2 Reference Specification. The HEAD element",
"sub": "W3C勧告1997年1月14日",
},
{
"title": "Hypertext Markup Language - 2.0. November 1995.",
"href": "https://www.ietf.org/rfc/rfc1866.txt",
"heading": "Hypertext Markup Language - 2.0",
"sub": "November 1995",
},
{
"title": "Hypertext Markup Language (HTML). June 1993.",
"href": "https://www.w3.org/MarkUp/draft-ietf-iiir-html-01.txt",
"heading": "Hypertext Markup Language (HTML)",
"sub": "June 1993",
},
{
"title": "MDN Web Docs. HTML <head>: The Document Metadata (Header) element.",
"href": "https://developer.mozilla.org/ja/docs/Web/HTML/Element/head",
"heading": "MDN Web Docs. HTML <head>: 文書メタデータ (ヘッダー) 要素",
},
],
"version": {
"first": "HTML",
"latest": "HTML Living Standard",
},
}
}
注意: 簡易に描画する為に、各項目の後ろに
,
を付与しています。JSON の形式では、末尾の項目の後には,
は付けません。 - 最終確認日
-
2024-09-01
2.使用できるコンテキスト
head要素
は、
html要素の
1番目の要素として
使用できます。
head
と言うよりhtml
html
<!DOCTYPE html>
<html lang=
"ja"> <head>
<meta charset=
"UTF-8"> <title>サンプル</title>
</head>
<body>
HTMLを用いると、テキストデータの表示等ができます。
</body>
</html
html
3.コンテンツモデル
head要素
は、
メタデータコンテンツを
配置できます。
head
別の言い方で細かく言うと、title
ただし、文書がフレームで読み込まれる文書である場合、またはタイトル情報が上位レベルのプロトコルから利用できる場合は、title
HTML3.2 までは、isindex
HTML2 までは、nextid
メタデータ
content
<head>
<meta charset=
"UTF-8"> <title>離珠のHTMLでしぃ!</title>
<base href=
"http://risyu.in .coocan.jp/ " target="_self"> <link rel=
"stylesheet" href= "style.css" type= "text/css"> <style>
body{ color: #ff0000; }
</style>
<script src=
"./script.js"></script> <noscript>
<link rel=
"stylesheet" href= "noscript.css" type= "text/css"> </noscript>
<template id=
"iteTemplate"> <!--ここにテンプレートを書く-->
</template>
</head>
charset
iframe
base
4.コンテンツ属性
head要素
は、
グローバル属性のみ、
設定できます。
head
head
profiledata-profile
とでも置き換えるのが良いでしょう。
5.DOM インターフェイス
documentの
プロパティである
headは、
head要素を返します。
document
.head .className= "ecoTest0000"; window
.alert( "document .head .className="+ document .head .className); window
.alert( document .documentElement .children[0] .className);
head
は、document
のプロパティであり、要素であるheadhead
プロパティは、読取専用です。変更しようとすると、エラーとなります。head
プロパティはオブジェクトです。オブジェクトのプロパティは、オブジェクトが読取専用であってもその制限は受けません。個々のプロパティが読取専用であるか否かです。なので、head
プロパティのclassName
プロパティに値を代入したり、headdocumentElement
プロパティの子要素のリストの1番目がhead
6.レンダリング
head {
display: none;
}
headnone
であり、この要素とその子孫はボックスやテキスト
head
head > * { display: none; }
head, title { display: block; }
title { margin-top: 11em; }
base::after { content: "target=" attr(target); }
メタデータを記述するエスケープ可能な生テキスト要素を表示する例のつもりです。表示する予定であれば、メタデータとしてではなく表示用でもあるデータとして別の要素で記述しておくのが良いかと思います。例として記述してみても、なんか変かなと思います。まぁ技術的な可能性としての知識として見てください。 実際、ファイルの文字数を考えてみても、スタイルシートの指定が必要になり、内容次第ではかえって増えます。
使用している外部ファイルへのリンクは、「./displaymetadata.htm」です。
7.気を付ける点
タグの省略の扱い
head
<!DOCTYPE html>
<html lang=
"ja"> <body>
<h1>離珠のHTMLでしぃ!</h1>
</body>
</html>
文書がiframe
タグの記述を省略しているだけで、要素は存在しています。