1.メタデータ関連の要素
HTML文書の
付加的な情報を表す
メタデータコンテンツを
まとめました。
HTMLには、付加的な情報を表す要素があります。それらをメタデータ
メタデータに関わる要素は、以下の各要素です。
- メタデータ
コンテンツ を含む為の要素- head
要素 : メタデータを含む(囲む, まとめる)
- head
- メタデータ
コンテンツ - meta
要素 : 一般的なメタ情報 - title
要素 : 文書の題名 - base
要素 : 文書の基底 URI - link
要素 : 外部リソースにリンク - style
要素 : スタイル情報 - スクリプトを
サポートする要素 - script
要素 : スクリプト - template
要素 : コンテンツの雛型
- script
- noscript
要素 : スクリプトが無効な場合 - isindex
要素 : 一行プロンプト (HTML4.01 で非推奨, HTML5 で廃止) - nextid
要素 : リンク名に使用する次の ID (HTML2 で非推奨, HTML3.2 で廃止)
- meta
2.HTML文書のメタデータ
メタデータは、
ページに関する
情報の事です。
メタデータ
は、あるデータが付随して持つそのデータ自身についての付加的なデータの事です。
「残りの
内容
- メタ
- メタデータ
コンテンツ - スク
- スクリプトを
サポートする要素 - フロー
- フロー
コンテンツ - 区分化
- セクショニング
コンテンツ - 起源
- セクショニング
ルート (廃止) - 見出し
- ヘディング
コンテンツ - フレー
- フレージング
コンテンツ - 埋込
- エンベデッド
コンテンツ - 対話型
- インタラクティブ
コンテンツ
要素 | 種類 | メ タ |
流 れ |
文 節 |
埋 込 |
対 話 |
知 覚 |
区 分 |
見 出 |
ス ク |
---|---|---|---|---|---|---|---|---|---|---|
meta | 空要素 | 〇 | ※ | ※ | - | - | - | - | - | - |
title | エスケープ | 〇 | - | - | - | - | - | - | - | - |
base | 空要素 | 〇 | - | - | - | - | - | - | - | - |
link | 空要素 | 〇 | ※ | ※ | - | - | - | - | - | - |
style | 生テキスト要素 | 〇 | - | - | - | - | - | - | - | - |
script | 生テキスト要素 | 〇 | 〇 | 〇 | - | - | - | - | - | 〇 |
noscript | 通常要素 | 〇 | 〇 | 〇 | - | - | - | - | - | - |
template | 雛型要素 | 〇 | 〇 | 〇 | - | - | - | - | - | 〇 |
3.メタデータの要素の配置
メタデータは、
主に head要素の
コンテンツとして
配置できます。
メタデータ
メタデータ
詳細は、各要素の説明のページで確認して下さい。
「メタ」は、メタデータ
link
script
4.スクリプトをサポートする要素
スクリプトをサポートする要素 は、
スクリプトをサポートする為の
要素の
カテゴリです。
それ自体は何も表さない (つまり、レンダリングされない) 要素ですが、スクリプトをサポートする為に使用される要素があります。それらをスクリプトを
スクリプトを
上記のスクリプトを
5.メタデータの雛型
<!DOCTYPE html>
<html lang=
"ja"> <head>
<meta charset=
"UTF-8"> <title>離珠のHTMLでしぃ!</title>
</head>
<body>
ここに文章を書く
</body>
</html
charset
<!DOCTYPE html>
<html lang=
"ja"> <head>
<meta charset=
"UTF-8"> <title>離珠のHTMLでしぃ!</title>
<base href=
"http://risyu .in " target=.coocan .jp/ Html/ "_self"> <meta name=
"viewport" content= "width=device-width, initial-scale=1 "><script
src="https://code.jquery.com/ jquery-3.2.1.js "
integrity="sha256-DZAnKJ/ 6XZ9si04Hgrsxu/ "8s717jcIzLy3oi35EouyE=
crossorigin="anonymous"></script> <script src=
"./risyu.js"></script> <link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ ajax/ "libs/ normalize/ 8.0.0/ normalize.css
integrity="sha384-jTFzRHnGayPcZHkUx5hTuWbygQevlGFimHdpRHicjyJXGyyjcioudSScb7/YN0PE" crossorigin= "anonymous"> <link rel=
"stylesheet" href= "./risyu.css"> <link rel=
"icon" href= "../favicon.ico" type= "image/ vnd.microsoft.icon "></head>
<body>
ここに文章を書く
</body>
</html
7行目は、筆者(わたし)としてはビューポートのサイズを制御するおまじないです。 まだ理解できていません。 8行目は jquery 10行目は normalize.css (CSSリセット) の例示です。
<!DOCTYPE html>
<html lang=
"ja"> <head> <meta charset= "UTF-8"> <title>離珠のHTMLでしぃ!</title>
<meta name=
"viewport" content= "width=device-width, initial-scale=1 "><script src=
"./risyu.js"></script> <link rel=
"stylesheet" href= "./risyu.css"> </head>
<body>
ここに文章を書く
</body>
</html
1行目は、文書型宣言だけです。1行目を文書型宣言と認識するユーザーエージェントがあったので、おまじないで1行目は文書型宣言だけです。
2行目は、html
3行目は、title
4行目は、ビューポートのサイズを制御する為にmeta
5行目は、スクリプトを記述する為にscript
6行目は、スタイルシートの読み込みを記述する為にlink
手書きで書き足す, 書き換える事を意識した雛型です。
<!DOCTYPE html>
<html lang=
"ja"> <head>
<meta charset=
"UTF-8"> <title>離珠のHTMLでしぃ!</title>
<base href=
"http://risyu .in " target=.coocan .jp/ Html/ "_self"> <link rel=
"icon" href= "../favicon.ico" type= "image/ vnd.microsoft.icon "><style>
body { color: #000000; }
</style>
<script>
document
.addEventListener( "DOMContentLoaded", function() {} if ("content" in document
.createElement( "template" ) ) { var leHtmlTemplate = document
.getElementById( "itpJs0101" ); var leHtmlClone = document
.importNode leHtmlTemplate .content, true); document
.getElementById( "idvJs0101" ) .appendChild( leHtmlClone ); }
}
</script>
<template id=
"itpJs0101"> <div>ひながた</div>
</template>
</head>
<body>
ここに文章を書く
<div id=
"idvJs0101"> <noscript>
スクリプトが無効です。
</noscript>
</div>
</body>
</html
この例は、メタデータ
6.Pugのサンプル
Pugでの
サンプルです。
著者(わたし)のPugを使う理由が、スタイルシートを使うにあたってのクラス属性の管理の為だったので このメタデータに関する処では関係なかったのですが メタデータの json ファイルによる管理という点で使えるかもという事で記述してみました。
{
"common" : {
"doctype" : "HTML5",
"charset" : "UTF-8",
"lang" : "ja",
"script" : ["./script.js"],
"stylesheet" : ["./stylesheet.css"],
"favicon" : "./favicon.ico"
}
}
block tpvariable
block tpmeta
case common.doctype
when 'HTML4.01 Transitional'
doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"
when 'HTML4.01 Frameset'
doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"
when 'HTML4.01 Strict'
doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"
when 'HTML3.2'
doctype HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"
when 'none'
- break
default
doctype html
html(lang=common.lang)
head
if common.doctype == 'HTML4.01 Transitional' || common.doctype == 'HTML4.01 Frameset' || common.doctype == 'HTML4.01 Strict'
meta(http-equiv="content-type" content="text/html; charset="+common.charset)
else
meta(charset=common.charset)
title #{page.title}
meta(name="viewport" content="width=device-width,initial-scale=1")
meta(name="description" content=page.description)
meta(name="author" content=page.author)
meta(name="build" content=page.build)
meta(name="date" content=page.date)
if common.script.length > 0
each _lsScript in common.script
script(src=_lsScript)
if page.googlefonts
link(rel="dns-prefetch" href="https://fonts.googleapis.com")
link(rel="preconnect" href="https://fonts.gstatic.com" crossorigin)
link(rel="stylesheet")&attributes({href : "https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;700&family=Dancing+Script&display=swap"})
if common.stylesheet.length > 0
each _lsStylesheet in common.stylesheet
link(rel="stylesheet" href=_lsStylesheet)
if common.favicon
link(rel="icon" href=common.favicon type="image/vnd.microsoft.icon")
block tpstyle
block tpscript
if common.doctype == 'HTML4.01 Frameset'
block tpframeset
else
block tpbody
extends ./_template
block prepend tpvariable
-
const page = {
title : 'タイトル',
description : '説明',
author : '著者名',
build : '2023-12-24',
date : '2023-12-31',
googlefonts : true,
};
block prepend tpbody
body
| さんぷる
<!DOCTYPE html>
<html lang=
"ja"> <head>
<meta charset=
"UTF-8"> <title>タイトル</title>
<meta name=
"viewport" content= "width= device-width, ">initial-scale=1 <meta name=
"description" content= "説明"> <meta name=
"author" content= "著者名"> <meta name=
"build" content= "2023-12-24"> <meta name=
"date" content= "2023-12-31"> <script src=
"./script.js"> </script> <link rel=
"dns-prefetch" href= "https://fonts .googleapis ">.com <link rel=
"preconnect" href= "https://fonts .gstatic " crossorigin>.com <link rel=
"stylesheet" href= "https://fonts .googleapis ">.com/ css2 ?family= Noto+Sans+JP :wght@400;700 &family= Dancing+Script &display=swap <link rel=
"stylesheet" href= "./stylesheet.css"> <link rel=
"icon" href= "./favicon.ico" type= "image/ vnd ">.microsoft .icon </head>
<body>さんぷる</body>
</html>
とりあえずのサンプルというか雛型です。 見た目のサンプルという事で、自分の命名規則なども外しています。