From 3c4f07e74418e941c10fc22f037793f718cae746 Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Fri, 14 Jan 2022 23:28:50 +0900 Subject: Web/HTML/Attributes を変換準備 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- files/ja/web/html/attributes/index.html | 769 -------------------------------- files/ja/web/html/attributes/index.md | 769 ++++++++++++++++++++++++++++++++ 2 files changed, 769 insertions(+), 769 deletions(-) delete mode 100644 files/ja/web/html/attributes/index.html create mode 100644 files/ja/web/html/attributes/index.md (limited to 'files/ja/web') diff --git a/files/ja/web/html/attributes/index.html b/files/ja/web/html/attributes/index.html deleted file mode 100644 index 62069e4ab3..0000000000 --- a/files/ja/web/html/attributes/index.html +++ /dev/null @@ -1,769 +0,0 @@ ---- -title: HTML 属性リファレンス -slug: Web/HTML/Attributes -tags: - - Attribute - - Attributes - - Beginner - - Configuring - - Element Attributes - - Elements - - HTML - - Reference - - Settings - - Web - - 初心者 - - 属性 - - 要素 - - 要素の属性 - - 設定 -translation_of: Web/HTML/Attributes ---- -
{{HTMLSidebar}}
- -

HTML の要素は属性を持ちます。ユーザーが望む基準を満たすために、さまざまな方法で要素を構成したり、動作を調整したりする追加の値です。

- -

属性一覧

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
属性名要素説明
accept{{ HTMLElement("form") }}, {{ HTMLElement("input") }}サーバーの受容する型のリストです。ファイル形式など。
accept-charset{{ HTMLElement("form") }}対応している文字集合の一覧です。
accesskeyグローバル属性要素をアクティブ化したり、フォーカスを与えたりするためのショートカットキーです。
action{{ HTMLElement("form") }}フォーム経由で送信される情報を処理するプログラムの URI です。
align{{ HTMLElement("applet") }}, {{ HTMLElement("caption") }}, {{ HTMLElement("col") }}, {{ HTMLElement("colgroup") }}, {{ HTMLElement("hr") }}, {{ HTMLElement("iframe") }}, {{ HTMLElement("img") }}, {{ HTMLElement("table") }}, {{ HTMLElement("tbody") }}, {{ HTMLElement("td") }}, {{ HTMLElement("tfoot") }} , {{ HTMLElement("th") }}, {{ HTMLElement("thead") }}, {{ HTMLElement("tr") }}要素の水平方向の配置を指定します。
allow{{ HTMLElement("iframe") }}iframe の機能ポリシーを指定します。
alt{{ HTMLElement("applet") }}, {{ HTMLElement("area") }}, {{ HTMLElement("img") }}, {{ HTMLElement("input") }}画像が表示できない場合の代替テキストです。
async{{ HTMLElement("script") }}スクリプトを非同期で実行します。
autocapitalizeグローバル属性ユーザーによる入力が入力欄で自動的に大文字化されるかどうかを設定します。
autocomplete{{ HTMLElement("form") }}, {{ HTMLElement("input") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}このフォーム内のコントロールが、ブラウザーによる値の自動補完を既定で許容するかを示します。
autofocus{{ HTMLElement("button") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}ページ読込後に、対象要素に自動的にフォーカスを当てるようにします。
autoplay{{ HTMLElement("audio") }}, {{ HTMLElement("video") }}オーディオやビデオが再生可能になった時点で自動再生を開始します。
background{{ HTMLElement("body") }}, {{ HTMLElement("table") }}, {{ HTMLElement("td") }}, {{ HTMLElement("th") }}画像ファイルの URL を指定します。 -
注: ブラウザーや電子メールクライアントはまだこの属性に対応していますが、廃止済みです。代わりに CSS の {{ Cssxref("background-image") }} を使用してください。
-
bgcolor{{ HTMLElement("body") }}, {{ HTMLElement("col") }}, {{ HTMLElement("colgroup") }}, {{ HTMLElement("marquee") }}, {{ HTMLElement("table") }}, {{ HTMLElement("tbody") }}, {{ HTMLElement("tfoot") }}, {{ HTMLElement("td") }}, {{ HTMLElement("th") }}, {{ HTMLElement("tr") }} -

要素の背景色です。

- -
-

注: これは古い属性です。代わりに CSS の {{ Cssxref("background-color") }} プロパティを使用してください。

-
-
border{{ HTMLElement("img") }}, {{ HTMLElement("object") }}, {{ HTMLElement("table") }} -

境界線の幅です。

- -
-

注: これは古い属性です。代わりに CSS の {{ Cssxref("border") }} プロパティを使用してください。

-
-
buffered{{ HTMLElement("audio") }}, {{ HTMLElement("video") }}すでにバッファリングされたメディアの時間の範囲を示します。
capture{{ HTMLElement("input") }}{{SpecName('HTML Media Capture', '#the-capture-attribute','media capture')}} 仕様書から、キャプチャできる新しいファイルを指定します。
challenge{{ HTMLElement("keygen") }}公開鍵とともに送信するチャレンジ文字列
charset{{ HTMLElement("meta") }}, {{ HTMLElement("script") }}ページまたはスクリプトの文字エンコーディングを宣言します。
checked{{ HTMLElement("command") }}, {{ HTMLElement("input") }}ページ読み込み時に要素にチェックを入れておくかどうかを指定します。
cite{{ HTMLElement("blockquote") }}, {{ HTMLElement("del") }}, {{ HTMLElement("ins") }}, {{ HTMLElement("q") }}引用元または変更点の情報源を指す URI を格納します。
classグローバル属性よく使われるプロパティで要素にスタイルを適用するために CSS と共によく用いられます。
code{{ HTMLElement("applet") }}読み込んで実行するアプレットのクラスファイルの URL を指定します。
codebase{{ HTMLElement("applet") }}code 属性で参照するアプレットの .class ファイルを配置しているディレクトリの絶対 URL または相対 URL を指定します。
color{{ HTMLElement("basefont") }}, {{ HTMLElement("font") }}, {{ HTMLElement("hr") }} -

この属性は色名または16進数の #RRGGBB 形式を用いて文字色を設定します。

- -
-

注: これは古い属性です。代わりに CSS の {{Cssxref("color")}} プロパティを使用して下さい。

-
-
cols{{ HTMLElement("textarea") }}テキストエリアの桁数 (水平方向の文字数) を定義します。
colspan{{ HTMLElement("td") }}, {{ HTMLElement("th") }}colspan 属性はテーブルのセルを結合する列数を定義します。
content{{ HTMLElement("meta") }}状況に応じて、 http-equiv または name に関連した値です。
contenteditableグローバル属性要素の内容が編集可能であるかどうかを示します。
contextmenuグローバル属性要素のコンテキストメニューとして機能する {{HTMLElement("menu")}} 要素の ID を定義します。
controls{{ HTMLElement("audio") }}, {{ HTMLElement("video") }}再生コントロールをユーザーに表示すべきかどうかを示します。
coords{{ HTMLElement("area") }}ホットスポット領域の座標を指定する為の値のセット
crossorigin{{ HTMLElement("audio") }}, {{ HTMLElement("img") }}, {{ HTMLElement("link") }}, {{ HTMLElement("script") }}, {{ HTMLElement("video") }}要素がオリジン間リクエストをどう扱うか
csp {{experimental_inline}}{{ HTMLElement("iframe") }}埋め込まれた文書が管理されるためのコンテンツセキュリティポリシーを指定します。
data{{ HTMLElement("object") }}リソースの URL を指定します。
data-*グローバル属性HTML 要素にカスタム属性が添付できるようにします。
datetime{{ HTMLElement("del") }}, {{ HTMLElement("ins") }}, {{ HTMLElement("time") }}要素に関連付けられた日時を示します。
decoding{{ HTMLElement("img") }}画像をデコードする推奨の方法をIndicates the preferred method to decode the image.
default{{ HTMLElement("track") }}ユーザ設定で別の項目を指定していない場合に、有効にするトラックを指定する
defer{{ HTMLElement("script") }}ページのパースが完了した後に実行するスクリプトであることを示す
dirグローバル属性テキストの書字方向を定義する。使用できる値は ltr (Left-To-Right) または rtl (Right-To-Left)
dirname{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}
disabled{{ HTMLElement("button") }}, {{ HTMLElement("command") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("optgroup") }}, {{ HTMLElement("option") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}閲覧者によるによるコントロールの操作を無効にするかどうかを示します。
download{{ HTMLElement("a") }}, {{ HTMLElement("area") }}リソースをダウンロードするためのハイパーリンクであるかどうかを示します。
draggableグローバル属性要素がドラッグ可能であるかどうかを示します。
dropzoneグローバル属性要素がその上でコンテンツのドロップ操作を受け付けるかどうかを示します。
enctype{{ HTMLElement("form") }}method 属性が POST である場合に、フォームデータのコンテンツタイプを定義します。
enterkeyhint {{experimental_inline}}{{ HTMLElement("textarea") }}, contenteditableenterkeyhint は、仮想キーボードの Enter キーにあるアクションラベル (またはアイコン) が何であるかを指定します。この属性はフォームコントロール (textarea 要素の値など) と共に、または編集対象となっている要素 (例えば contenteditable 属性の使用など) の中で使用することができます。
for{{ HTMLElement("label") }}, {{ HTMLElement("output") }}この要素が属する要素を指定します。
form{{ HTMLElement("button") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("label") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("object") }}, {{ HTMLElement("output") }}, {{ HTMLElement("progress") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}その要素が所属するフォームを示します。
formaction{{ HTMLElement("input") }}, {{ HTMLElement("button") }}その要素のアクションを示します。 {{ HTMLElement("form") }} で定義されたアクションを上書きします。
formenctype{{ HTMLElement("button") }}, {{ HTMLElement("input") }}button や input が送信ボタンである場合 (type="submit")、この属性はフォーム送信で使用するエンコーディング型を設定します。この属性が指定された場合、ボタンを所有するフォームenctype 属性より優先されます。
formmethod{{ HTMLElement("button") }}, {{ HTMLElement("input") }}button や input が送信ボタンである場合 (type="submit")、この属性はフォーム送信で使用する送信メソッド (GET, POST, など) を設定します。この属性が指定された場合、ボタンを所有するフォームmethod 属性より優先されます。
formnovalidate{{ HTMLElement("button") }}, {{ HTMLElement("input") }}button や input が送信ボタンである場合 (type="submit")、この論理属性はフォームが送信時に検証されないことを指定します。この属性が指定された場合、ボタンを所有するフォームnovalidate 属性より優先されます。
formtarget{{ HTMLElement("button") }}, {{ HTMLElement("input") }}button や input が送信ボタンである場合 (type="submit")、この属性はフォームを送信した後で受け取るレスポンスを表示する閲覧コンテキスト (例えば、タブ、ウィンドウ、インラインフレーム) を指定します。この属性が指定された場合、ボタンを所有するフォームtarget 属性より優先されます。
headers{{ HTMLElement("td") }}, {{ HTMLElement("th") }}この要素に適用する <th> 要素の ID。
height{{ HTMLElement("canvas") }}, {{ HTMLElement("embed") }}, {{ HTMLElement("iframe") }}, {{ HTMLElement("img") }}, {{ HTMLElement("input") }}, {{ HTMLElement("object") }}, {{ HTMLElement("video") }} -

ここに挙げた要素の高さを指定します。他の要素では、 {{cssxref("height")}} プロパティを使用してください。

- -
-

注: {{HTMLElement("div")}} など一部の要素では、これは古い属性であり、代わりに CSS の {{Cssxref("height")}} プロパティを使用してください。

-
-
hiddenグローバル属性この要素のレンダリングを抑制しますが、 script 要素などの子要素は有効なままにします。
high{{ HTMLElement("meter") }}最大値の下限を示します。
href{{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("base") }}, {{ HTMLElement("link") }}リンクされたリソースの URL です。
hreflang{{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("link") }}リンクされたリソースの言語を指定します。
http-equiv{{ HTMLElement("meta") }}プラグマディレクティブを定義します。
icon{{ HTMLElement("command") }}コマンドを表す画像を指定します。
idグローバル属性特定の要素へスタイルを設定するために CSS と共によく使われます。この属性の値は一位でなければなりません。
importance {{experimental_inline}}{{ HTMLElement("iframe") }}, {{ HTMLElement("img") }}, {{ HTMLElement("link") }}, {{ HTMLElement("script") }}リソースの相対的なフェッチ優先順位を示します。
integrity{{ HTMLElement("link") }}, {{ HTMLElement("script") }} -

ブラウザーが読み込むものを検証できるようにするためのサブリソース完全性の値を指定します。

-
intrinsicsize {{deprecated_inline}}{{ HTMLElement("img") }}この属性は、ブラウザーに画像に交友の実際の寸法を無視して、属性で指定された寸法を割り当てるように指示します。
inputmode{{ HTMLElement("textarea") }}, contenteditable要素やその内容を編集する際に、ユーザーが入力する可能性のあるデータの種類のヒントを提供します。この属性はフォームコントロール (textarea 要素の値など) と共に、または編集対象となっている要素 (例えば contenteditable 属性の使用など) の中で使用することができます。
ismap{{ HTMLElement("img") }}画像がサーバーサイドイメージマップの一部であることを示します。
itempropグローバル属性
keytype{{ HTMLElement("keygen") }}生成する鍵の種類を指定します。
kind{{ HTMLElement("track") }}テキストトラックの種類を指定します。
label{{ HTMLElement("optgroup") }}, {{ HTMLElement("option") }}, {{ HTMLElement("track") }}ユーザーが読める形の要素のタイトルを指定します。
langグローバル属性要素内で用いられている言語を定義する。
language{{ HTMLElement("script") }}要素で使用しているスクリプト言語を定義する。
loading {{experimental_inline}}{{ HTMLElement("img") }}, {{ HTMLElement("iframe") }}要素を遅延読み込みさせたいこと (loading="lazy") または直ちに読み込ませたいこと (loading="eager") を示します。 - -
list{{ HTMLElement("input") }}ユーザに提案するため、事前に定義した選択肢のリストを示す。
loop{{ HTMLElement("audio") }}, {{ HTMLElement("bgsound") }}, {{ HTMLElement("marquee") }}, {{ HTMLElement("video") }}メディアの再生が完了した後、始めから再生を開始するかを示します。
low{{ HTMLElement("meter") }}最小値の上限を示します。
manifest{{ HTMLElement("html") }}ドキュメントのキャッシュマニフェストの URL を指定します。 -
注: この属性は廃止されており、代わりに <link rel="manifest"> を使用してください。
-
max{{ HTMLElement("input") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("progress") }}許容される最大の値を示す。
maxlength{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}要素が許容する最大文字数を定義します。
minlength{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}要素が許容する最小文字数を定義する。
media{{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("link") }}, {{ HTMLElement("source") }}, {{ HTMLElement("style") }}リンクされたリソースがどのメディアに対して設計されたかを指定する。ンn
method{{ HTMLElement("form") }}フォームを送信する際に使用する HTTP メソッドを定義する。 GET (既定値) または POST を指定可能。
min{{ HTMLElement("input") }}, {{ HTMLElement("meter") }}許容される最小の値を示す。
multiple{{ HTMLElement("input") }}, {{ HTMLElement("select") }}type が email または file の input では、複数の値を入力可能かを示す。
muted{{ HTMLElement("audio") }}, {{ HTMLElement("video") }}ページ読み込み時に音声を無音にするかどうかを示します。
name{{ HTMLElement("button") }}, {{ HTMLElement("form") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("iframe") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("object") }}, {{ HTMLElement("output") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}, {{ HTMLElement("map") }}, {{ HTMLElement("meta") }}, {{ HTMLElement("param") }}要素の名前。例えば、送信されたフォームでサーバーがフィールドを識別するために使用する。
novalidate{{ HTMLElement("form") }}送信時にフォームが検証されないようにする。
open{{ HTMLElement("details") }}ページ読み込み時に詳細情報を表示するかを示す。
optimum{{ HTMLElement("meter") }}最適な値を示す。
pattern{{ HTMLElement("input") }}要素の値を検証する正規表現を定義する。
ping{{ HTMLElement("a") }}, {{ HTMLElement("area") }}ping 属性は、ユーザーがハイパーリンクをたどる場合に通知される URL のリストを空白区切りで指定します。
placeholder{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}フィールドが何を入力するものであるかのヒントを閲覧者に対し提供する。
poster{{ HTMLElement("video") }}ユーザが再生やシークを行うまでの間に表示するポスターフレームの URL。
preload{{ HTMLElement("audio") }}, {{ HTMLElement("video") }}リソースの全体または一部のプリロードを行う、あるいはプリロードを行わないことを示す。
radiogroup{{ HTMLElement("command") }}
readonly{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}要素が編集できるかどうかを示す。
referrerpolicy{{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("iframe") }}, {{ HTMLElement("img") }}, {{ HTMLElement("link") }}, {{ HTMLElement("script") }}リソースにアクセスする際にどのリファラーが送信されるかを指定する。
rel{{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("link") }}リンク先オブジェクトとリンク元オブジェクトとの関係を指定する。
required{{ HTMLElement("input") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}入力が必須の要素であるかを示す。
reversed{{ HTMLElement("ol") }}リストを昇順ではなく降順に表示することを示す。
rows{{ HTMLElement("textarea") }}textarea の行数を定義する。
rowspan{{ HTMLElement("td") }}, {{ HTMLElement("th") }}テーブルセルがまたがる行数を定義する。
sandbox{{ HTMLElement("iframe") }}iframe に読み込まれた文書で特定の機能を使用することを止める (フォームの投稿や新しいウィンドウを開くなど)。
scope{{ HTMLElement("th") }}(th 要素で定義される) ヘッダーテストが関連するセルを定義します。
scoped{{ HTMLElement("style") }}
selected{{ HTMLElement("option") }}ページ読込時に、対象要素を選択状態にする。
shape{{ HTMLElement("a") }}, {{ HTMLElement("area") }}
size{{ HTMLElement("input") }}, {{ HTMLElement("select") }}要素の幅を定義する (ピクセル値)。要素の type 属性が text または password である場合は文字数になる。
sizes{{ HTMLElement("link") }}, {{ HTMLElement("img") }}, {{ HTMLElement("source") }}
slotグローバル属性要素にシャドウ DOM のシャドウツリーのスロットを割り当てます。
span{{ HTMLElement("col") }}, {{ HTMLElement("colgroup") }}
spellcheckグローバル属性要素のスペルチェックを有効にするかどうかを示します。
src{{ HTMLElement("audio") }}, {{ HTMLElement("embed") }}, {{ HTMLElement("iframe") }}, {{ HTMLElement("img") }}, {{ HTMLElement("input") }}, {{ HTMLElement("script") }}, {{ HTMLElement("source") }}, {{ HTMLElement("track") }}, {{ HTMLElement("video") }}埋め込みコンテンツの URL。
srcdoc{{ HTMLElement("iframe") }}
srclang{{ HTMLElement("track") }}
srcset{{ HTMLElement("img") }}, {{ HTMLElement("source") }}一つ以上のレスポンシブ画像の候補です。
start{{ HTMLElement("ol") }}1以外から始まる場合の最初の値を定義します。
step{{ HTMLElement("input") }}
styleグローバル属性外部スタイルシートや style 要素内に記述されたものより優先度の高いスタイル情報を記述する。
summary{{ HTMLElement("table") }}
tabindexグローバル属性ブラウザーによる既定のタブオーダーを無効化して、指定した順序に従うようにします。
target{{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("base") }}, {{ HTMLElement("form") }}
titleグローバル属性要素の示す範囲のタイトル。PC ブラウザーでは、マウスオーバー時にツールチップとしてその属性値が表示される。
translateグローバル属性ページが翻訳版である場合、要素の属性値と子の Text ノードが翻訳されているか、変更せずにそのままであるかを指定します。
type{{ HTMLElement("button") }}, {{ HTMLElement("input") }}, {{ HTMLElement("command") }}, {{ HTMLElement("embed") }}, {{ HTMLElement("object") }}, {{ HTMLElement("script") }}, {{ HTMLElement("source") }}, {{ HTMLElement("style") }}, {{ HTMLElement("menu") }}要素の型を定義する。
usemap{{ HTMLElement("img") }}, {{ HTMLElement("input") }}, {{ HTMLElement("object") }}
value{{ HTMLElement("button") }}, {{ HTMLElement("data") }}, {{ HTMLElement("input") }}, {{ HTMLElement("li") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("option") }}, {{ HTMLElement("progress") }}, {{ HTMLElement("param") }}ページ読み込み時に要素で表示するデフォルト値を定義する。
width{{ HTMLElement("canvas") }}, {{ HTMLElement("embed") }}, {{ HTMLElement("iframe") }}, {{ HTMLElement("img") }}, {{ HTMLElement("input") }}, {{ HTMLElement("object") }}, {{ HTMLElement("video") }} -

ここに挙げられた要素に対して、要素の幅を指定します。

- -
-

注: {{ HTMLElement("div") }} など他の要素については、これは古い属性であり、代わりに CSS の {{ Cssxref("width") }} プロパティを使用してください。

-
-
wrap{{ HTMLElement("textarea") }}テキストを折り返すかどうかを示します。
- -

content 属性と IDL 属性

- -

HTML では、ほとんどの属性に content 属性IDL (Interface Definition Language) 属性 の 2 つの側面があります。

- -

content 属性は content (HTML コード) から設定する属性であり、 {{domxref("element.setAttribute()")}} や {{domxref("element.getAttribute()")}} を使用して設定あるいは取得できます。 content 属性は値として数値を想定するものであっても、常に文字列です。例えば content 属性を使用して {{HTMLElement("input")}} 要素の maxlength 属性に 42 を設定するには、その要素で setAttribute("maxlength", "42") を呼び出さなければなりません。

- -

IDL 属性は JavaScript プロパティとしても知られています。これらは element.foo といった JavaScript プロパティを使用して読み書きします。IDL 属性は読み取り時に値を返すため基になる content 属性を使用 (ただし、変換するでしょう) したり、書き込み時に content 属性へ何らかの値を保存したりします。言い換えると、IDL 属性は content 属性を映し出します。

- -

ほとんどの場合、IDL 属性は実際に使用する値として自身の値を返します。例えば {{HTMLElement("input")}} 要素の type 属性のデフォルト値は "text" であるので、input.type="foobar" を設定すると <input> 要素は (外見と動作が) text タイプになりますが、"type" content 属性の値は "foobar" になります。しかし、type IDL 属性は文字列 "text" を返します。

- -

IDL 属性は常に文字列とは限りません。例えば input.maxlength は数値 (符号付き long) です。IDL 属性を使用するときは望ましい型の値を読み書きするので、input.maxlength は常に数値を返し、また input.maxlength を設定するときは数値を要求します。他の型で渡すと、標準的な JavaScript の型変換規則に従って自動的に数値へ変換されます。

- -

IDL 属性は符号なし long、URL、論理値など他の型を反映することが可能です。残念ながら、属性に応じて IDL 属性が対応する content 属性と一体化して動作するための明確な規則や方法はありません。ほとんどの場合は仕様にある規則に従いますが、そうでない場合もあります。 HTML 仕様では可能な限り開発者にやさしいものにしようとしていますが、さまざまな理由 (たいていは歴史的な理由) により奇妙な動作になる属性 (例えば select.size) があり、実際どのように動作するかを理解するために仕様書を読むようにしましょう。

- -

論理属性

- -

一部のコンテンツ属性 (例えば required, readonly, disabled) は論理属性 (boolean attributes) と呼ばれています。論理属性は存在すれば、その値は true となり、存在しなければ、その値は false となります。

- -

HTML5 では、論理属性に許されている値の制約を定義しています。属性が存在する場合は、値は空文字列 (属性の値が割り当てられないことがあります) または属性の正式名に ASCII で大文字・小文字まで一致する値のどちらかで、前後にホワイトスペースを含んではいけません。以下の例は論理属性をマークアップする正しい方法です。

- -
<div itemscope> This is valid HTML but invalid XML. </div>
-<div itemscope=itemscope> This is also valid HTML but invalid XML. </div>
-<div itemscope=""> This is valid HTML and also valid XML. </div>
-<div itemscope="itemscope"> This is also valid HTML and XML, but perhaps a bit verbose. </div>
- -

明確にするために、 "true" および "false" という値は論理属性では許可されていません。偽の値を表すには、属性ごと省略する必要があります。この制約により、いくつかのよくある誤解が明確になります。例えば checked="false" は、属性が存在するため、その要素の checked 属性が true であると解釈されます。

- -

関連情報

- - diff --git a/files/ja/web/html/attributes/index.md b/files/ja/web/html/attributes/index.md new file mode 100644 index 0000000000..62069e4ab3 --- /dev/null +++ b/files/ja/web/html/attributes/index.md @@ -0,0 +1,769 @@ +--- +title: HTML 属性リファレンス +slug: Web/HTML/Attributes +tags: + - Attribute + - Attributes + - Beginner + - Configuring + - Element Attributes + - Elements + - HTML + - Reference + - Settings + - Web + - 初心者 + - 属性 + - 要素 + - 要素の属性 + - 設定 +translation_of: Web/HTML/Attributes +--- +
{{HTMLSidebar}}
+ +

HTML の要素は属性を持ちます。ユーザーが望む基準を満たすために、さまざまな方法で要素を構成したり、動作を調整したりする追加の値です。

+ +

属性一覧

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
属性名要素説明
accept{{ HTMLElement("form") }}, {{ HTMLElement("input") }}サーバーの受容する型のリストです。ファイル形式など。
accept-charset{{ HTMLElement("form") }}対応している文字集合の一覧です。
accesskeyグローバル属性要素をアクティブ化したり、フォーカスを与えたりするためのショートカットキーです。
action{{ HTMLElement("form") }}フォーム経由で送信される情報を処理するプログラムの URI です。
align{{ HTMLElement("applet") }}, {{ HTMLElement("caption") }}, {{ HTMLElement("col") }}, {{ HTMLElement("colgroup") }}, {{ HTMLElement("hr") }}, {{ HTMLElement("iframe") }}, {{ HTMLElement("img") }}, {{ HTMLElement("table") }}, {{ HTMLElement("tbody") }}, {{ HTMLElement("td") }}, {{ HTMLElement("tfoot") }} , {{ HTMLElement("th") }}, {{ HTMLElement("thead") }}, {{ HTMLElement("tr") }}要素の水平方向の配置を指定します。
allow{{ HTMLElement("iframe") }}iframe の機能ポリシーを指定します。
alt{{ HTMLElement("applet") }}, {{ HTMLElement("area") }}, {{ HTMLElement("img") }}, {{ HTMLElement("input") }}画像が表示できない場合の代替テキストです。
async{{ HTMLElement("script") }}スクリプトを非同期で実行します。
autocapitalizeグローバル属性ユーザーによる入力が入力欄で自動的に大文字化されるかどうかを設定します。
autocomplete{{ HTMLElement("form") }}, {{ HTMLElement("input") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}このフォーム内のコントロールが、ブラウザーによる値の自動補完を既定で許容するかを示します。
autofocus{{ HTMLElement("button") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}ページ読込後に、対象要素に自動的にフォーカスを当てるようにします。
autoplay{{ HTMLElement("audio") }}, {{ HTMLElement("video") }}オーディオやビデオが再生可能になった時点で自動再生を開始します。
background{{ HTMLElement("body") }}, {{ HTMLElement("table") }}, {{ HTMLElement("td") }}, {{ HTMLElement("th") }}画像ファイルの URL を指定します。 +
注: ブラウザーや電子メールクライアントはまだこの属性に対応していますが、廃止済みです。代わりに CSS の {{ Cssxref("background-image") }} を使用してください。
+
bgcolor{{ HTMLElement("body") }}, {{ HTMLElement("col") }}, {{ HTMLElement("colgroup") }}, {{ HTMLElement("marquee") }}, {{ HTMLElement("table") }}, {{ HTMLElement("tbody") }}, {{ HTMLElement("tfoot") }}, {{ HTMLElement("td") }}, {{ HTMLElement("th") }}, {{ HTMLElement("tr") }} +

要素の背景色です。

+ +
+

注: これは古い属性です。代わりに CSS の {{ Cssxref("background-color") }} プロパティを使用してください。

+
+
border{{ HTMLElement("img") }}, {{ HTMLElement("object") }}, {{ HTMLElement("table") }} +

境界線の幅です。

+ +
+

注: これは古い属性です。代わりに CSS の {{ Cssxref("border") }} プロパティを使用してください。

+
+
buffered{{ HTMLElement("audio") }}, {{ HTMLElement("video") }}すでにバッファリングされたメディアの時間の範囲を示します。
capture{{ HTMLElement("input") }}{{SpecName('HTML Media Capture', '#the-capture-attribute','media capture')}} 仕様書から、キャプチャできる新しいファイルを指定します。
challenge{{ HTMLElement("keygen") }}公開鍵とともに送信するチャレンジ文字列
charset{{ HTMLElement("meta") }}, {{ HTMLElement("script") }}ページまたはスクリプトの文字エンコーディングを宣言します。
checked{{ HTMLElement("command") }}, {{ HTMLElement("input") }}ページ読み込み時に要素にチェックを入れておくかどうかを指定します。
cite{{ HTMLElement("blockquote") }}, {{ HTMLElement("del") }}, {{ HTMLElement("ins") }}, {{ HTMLElement("q") }}引用元または変更点の情報源を指す URI を格納します。
classグローバル属性よく使われるプロパティで要素にスタイルを適用するために CSS と共によく用いられます。
code{{ HTMLElement("applet") }}読み込んで実行するアプレットのクラスファイルの URL を指定します。
codebase{{ HTMLElement("applet") }}code 属性で参照するアプレットの .class ファイルを配置しているディレクトリの絶対 URL または相対 URL を指定します。
color{{ HTMLElement("basefont") }}, {{ HTMLElement("font") }}, {{ HTMLElement("hr") }} +

この属性は色名または16進数の #RRGGBB 形式を用いて文字色を設定します。

+ +
+

注: これは古い属性です。代わりに CSS の {{Cssxref("color")}} プロパティを使用して下さい。

+
+
cols{{ HTMLElement("textarea") }}テキストエリアの桁数 (水平方向の文字数) を定義します。
colspan{{ HTMLElement("td") }}, {{ HTMLElement("th") }}colspan 属性はテーブルのセルを結合する列数を定義します。
content{{ HTMLElement("meta") }}状況に応じて、 http-equiv または name に関連した値です。
contenteditableグローバル属性要素の内容が編集可能であるかどうかを示します。
contextmenuグローバル属性要素のコンテキストメニューとして機能する {{HTMLElement("menu")}} 要素の ID を定義します。
controls{{ HTMLElement("audio") }}, {{ HTMLElement("video") }}再生コントロールをユーザーに表示すべきかどうかを示します。
coords{{ HTMLElement("area") }}ホットスポット領域の座標を指定する為の値のセット
crossorigin{{ HTMLElement("audio") }}, {{ HTMLElement("img") }}, {{ HTMLElement("link") }}, {{ HTMLElement("script") }}, {{ HTMLElement("video") }}要素がオリジン間リクエストをどう扱うか
csp {{experimental_inline}}{{ HTMLElement("iframe") }}埋め込まれた文書が管理されるためのコンテンツセキュリティポリシーを指定します。
data{{ HTMLElement("object") }}リソースの URL を指定します。
data-*グローバル属性HTML 要素にカスタム属性が添付できるようにします。
datetime{{ HTMLElement("del") }}, {{ HTMLElement("ins") }}, {{ HTMLElement("time") }}要素に関連付けられた日時を示します。
decoding{{ HTMLElement("img") }}画像をデコードする推奨の方法をIndicates the preferred method to decode the image.
default{{ HTMLElement("track") }}ユーザ設定で別の項目を指定していない場合に、有効にするトラックを指定する
defer{{ HTMLElement("script") }}ページのパースが完了した後に実行するスクリプトであることを示す
dirグローバル属性テキストの書字方向を定義する。使用できる値は ltr (Left-To-Right) または rtl (Right-To-Left)
dirname{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}
disabled{{ HTMLElement("button") }}, {{ HTMLElement("command") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("optgroup") }}, {{ HTMLElement("option") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}閲覧者によるによるコントロールの操作を無効にするかどうかを示します。
download{{ HTMLElement("a") }}, {{ HTMLElement("area") }}リソースをダウンロードするためのハイパーリンクであるかどうかを示します。
draggableグローバル属性要素がドラッグ可能であるかどうかを示します。
dropzoneグローバル属性要素がその上でコンテンツのドロップ操作を受け付けるかどうかを示します。
enctype{{ HTMLElement("form") }}method 属性が POST である場合に、フォームデータのコンテンツタイプを定義します。
enterkeyhint {{experimental_inline}}{{ HTMLElement("textarea") }}, contenteditableenterkeyhint は、仮想キーボードの Enter キーにあるアクションラベル (またはアイコン) が何であるかを指定します。この属性はフォームコントロール (textarea 要素の値など) と共に、または編集対象となっている要素 (例えば contenteditable 属性の使用など) の中で使用することができます。
for{{ HTMLElement("label") }}, {{ HTMLElement("output") }}この要素が属する要素を指定します。
form{{ HTMLElement("button") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("label") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("object") }}, {{ HTMLElement("output") }}, {{ HTMLElement("progress") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}その要素が所属するフォームを示します。
formaction{{ HTMLElement("input") }}, {{ HTMLElement("button") }}その要素のアクションを示します。 {{ HTMLElement("form") }} で定義されたアクションを上書きします。
formenctype{{ HTMLElement("button") }}, {{ HTMLElement("input") }}button や input が送信ボタンである場合 (type="submit")、この属性はフォーム送信で使用するエンコーディング型を設定します。この属性が指定された場合、ボタンを所有するフォームenctype 属性より優先されます。
formmethod{{ HTMLElement("button") }}, {{ HTMLElement("input") }}button や input が送信ボタンである場合 (type="submit")、この属性はフォーム送信で使用する送信メソッド (GET, POST, など) を設定します。この属性が指定された場合、ボタンを所有するフォームmethod 属性より優先されます。
formnovalidate{{ HTMLElement("button") }}, {{ HTMLElement("input") }}button や input が送信ボタンである場合 (type="submit")、この論理属性はフォームが送信時に検証されないことを指定します。この属性が指定された場合、ボタンを所有するフォームnovalidate 属性より優先されます。
formtarget{{ HTMLElement("button") }}, {{ HTMLElement("input") }}button や input が送信ボタンである場合 (type="submit")、この属性はフォームを送信した後で受け取るレスポンスを表示する閲覧コンテキスト (例えば、タブ、ウィンドウ、インラインフレーム) を指定します。この属性が指定された場合、ボタンを所有するフォームtarget 属性より優先されます。
headers{{ HTMLElement("td") }}, {{ HTMLElement("th") }}この要素に適用する <th> 要素の ID。
height{{ HTMLElement("canvas") }}, {{ HTMLElement("embed") }}, {{ HTMLElement("iframe") }}, {{ HTMLElement("img") }}, {{ HTMLElement("input") }}, {{ HTMLElement("object") }}, {{ HTMLElement("video") }} +

ここに挙げた要素の高さを指定します。他の要素では、 {{cssxref("height")}} プロパティを使用してください。

+ +
+

注: {{HTMLElement("div")}} など一部の要素では、これは古い属性であり、代わりに CSS の {{Cssxref("height")}} プロパティを使用してください。

+
+
hiddenグローバル属性この要素のレンダリングを抑制しますが、 script 要素などの子要素は有効なままにします。
high{{ HTMLElement("meter") }}最大値の下限を示します。
href{{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("base") }}, {{ HTMLElement("link") }}リンクされたリソースの URL です。
hreflang{{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("link") }}リンクされたリソースの言語を指定します。
http-equiv{{ HTMLElement("meta") }}プラグマディレクティブを定義します。
icon{{ HTMLElement("command") }}コマンドを表す画像を指定します。
idグローバル属性特定の要素へスタイルを設定するために CSS と共によく使われます。この属性の値は一位でなければなりません。
importance {{experimental_inline}}{{ HTMLElement("iframe") }}, {{ HTMLElement("img") }}, {{ HTMLElement("link") }}, {{ HTMLElement("script") }}リソースの相対的なフェッチ優先順位を示します。
integrity{{ HTMLElement("link") }}, {{ HTMLElement("script") }} +

ブラウザーが読み込むものを検証できるようにするためのサブリソース完全性の値を指定します。

+
intrinsicsize {{deprecated_inline}}{{ HTMLElement("img") }}この属性は、ブラウザーに画像に交友の実際の寸法を無視して、属性で指定された寸法を割り当てるように指示します。
inputmode{{ HTMLElement("textarea") }}, contenteditable要素やその内容を編集する際に、ユーザーが入力する可能性のあるデータの種類のヒントを提供します。この属性はフォームコントロール (textarea 要素の値など) と共に、または編集対象となっている要素 (例えば contenteditable 属性の使用など) の中で使用することができます。
ismap{{ HTMLElement("img") }}画像がサーバーサイドイメージマップの一部であることを示します。
itempropグローバル属性
keytype{{ HTMLElement("keygen") }}生成する鍵の種類を指定します。
kind{{ HTMLElement("track") }}テキストトラックの種類を指定します。
label{{ HTMLElement("optgroup") }}, {{ HTMLElement("option") }}, {{ HTMLElement("track") }}ユーザーが読める形の要素のタイトルを指定します。
langグローバル属性要素内で用いられている言語を定義する。
language{{ HTMLElement("script") }}要素で使用しているスクリプト言語を定義する。
loading {{experimental_inline}}{{ HTMLElement("img") }}, {{ HTMLElement("iframe") }}要素を遅延読み込みさせたいこと (loading="lazy") または直ちに読み込ませたいこと (loading="eager") を示します。 + +
list{{ HTMLElement("input") }}ユーザに提案するため、事前に定義した選択肢のリストを示す。
loop{{ HTMLElement("audio") }}, {{ HTMLElement("bgsound") }}, {{ HTMLElement("marquee") }}, {{ HTMLElement("video") }}メディアの再生が完了した後、始めから再生を開始するかを示します。
low{{ HTMLElement("meter") }}最小値の上限を示します。
manifest{{ HTMLElement("html") }}ドキュメントのキャッシュマニフェストの URL を指定します。 +
注: この属性は廃止されており、代わりに <link rel="manifest"> を使用してください。
+
max{{ HTMLElement("input") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("progress") }}許容される最大の値を示す。
maxlength{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}要素が許容する最大文字数を定義します。
minlength{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}要素が許容する最小文字数を定義する。
media{{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("link") }}, {{ HTMLElement("source") }}, {{ HTMLElement("style") }}リンクされたリソースがどのメディアに対して設計されたかを指定する。ンn
method{{ HTMLElement("form") }}フォームを送信する際に使用する HTTP メソッドを定義する。 GET (既定値) または POST を指定可能。
min{{ HTMLElement("input") }}, {{ HTMLElement("meter") }}許容される最小の値を示す。
multiple{{ HTMLElement("input") }}, {{ HTMLElement("select") }}type が email または file の input では、複数の値を入力可能かを示す。
muted{{ HTMLElement("audio") }}, {{ HTMLElement("video") }}ページ読み込み時に音声を無音にするかどうかを示します。
name{{ HTMLElement("button") }}, {{ HTMLElement("form") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("iframe") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("object") }}, {{ HTMLElement("output") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}, {{ HTMLElement("map") }}, {{ HTMLElement("meta") }}, {{ HTMLElement("param") }}要素の名前。例えば、送信されたフォームでサーバーがフィールドを識別するために使用する。
novalidate{{ HTMLElement("form") }}送信時にフォームが検証されないようにする。
open{{ HTMLElement("details") }}ページ読み込み時に詳細情報を表示するかを示す。
optimum{{ HTMLElement("meter") }}最適な値を示す。
pattern{{ HTMLElement("input") }}要素の値を検証する正規表現を定義する。
ping{{ HTMLElement("a") }}, {{ HTMLElement("area") }}ping 属性は、ユーザーがハイパーリンクをたどる場合に通知される URL のリストを空白区切りで指定します。
placeholder{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}フィールドが何を入力するものであるかのヒントを閲覧者に対し提供する。
poster{{ HTMLElement("video") }}ユーザが再生やシークを行うまでの間に表示するポスターフレームの URL。
preload{{ HTMLElement("audio") }}, {{ HTMLElement("video") }}リソースの全体または一部のプリロードを行う、あるいはプリロードを行わないことを示す。
radiogroup{{ HTMLElement("command") }}
readonly{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}要素が編集できるかどうかを示す。
referrerpolicy{{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("iframe") }}, {{ HTMLElement("img") }}, {{ HTMLElement("link") }}, {{ HTMLElement("script") }}リソースにアクセスする際にどのリファラーが送信されるかを指定する。
rel{{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("link") }}リンク先オブジェクトとリンク元オブジェクトとの関係を指定する。
required{{ HTMLElement("input") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}入力が必須の要素であるかを示す。
reversed{{ HTMLElement("ol") }}リストを昇順ではなく降順に表示することを示す。
rows{{ HTMLElement("textarea") }}textarea の行数を定義する。
rowspan{{ HTMLElement("td") }}, {{ HTMLElement("th") }}テーブルセルがまたがる行数を定義する。
sandbox{{ HTMLElement("iframe") }}iframe に読み込まれた文書で特定の機能を使用することを止める (フォームの投稿や新しいウィンドウを開くなど)。
scope{{ HTMLElement("th") }}(th 要素で定義される) ヘッダーテストが関連するセルを定義します。
scoped{{ HTMLElement("style") }}
selected{{ HTMLElement("option") }}ページ読込時に、対象要素を選択状態にする。
shape{{ HTMLElement("a") }}, {{ HTMLElement("area") }}
size{{ HTMLElement("input") }}, {{ HTMLElement("select") }}要素の幅を定義する (ピクセル値)。要素の type 属性が text または password である場合は文字数になる。
sizes{{ HTMLElement("link") }}, {{ HTMLElement("img") }}, {{ HTMLElement("source") }}
slotグローバル属性要素にシャドウ DOM のシャドウツリーのスロットを割り当てます。
span{{ HTMLElement("col") }}, {{ HTMLElement("colgroup") }}
spellcheckグローバル属性要素のスペルチェックを有効にするかどうかを示します。
src{{ HTMLElement("audio") }}, {{ HTMLElement("embed") }}, {{ HTMLElement("iframe") }}, {{ HTMLElement("img") }}, {{ HTMLElement("input") }}, {{ HTMLElement("script") }}, {{ HTMLElement("source") }}, {{ HTMLElement("track") }}, {{ HTMLElement("video") }}埋め込みコンテンツの URL。
srcdoc{{ HTMLElement("iframe") }}
srclang{{ HTMLElement("track") }}
srcset{{ HTMLElement("img") }}, {{ HTMLElement("source") }}一つ以上のレスポンシブ画像の候補です。
start{{ HTMLElement("ol") }}1以外から始まる場合の最初の値を定義します。
step{{ HTMLElement("input") }}
styleグローバル属性外部スタイルシートや style 要素内に記述されたものより優先度の高いスタイル情報を記述する。
summary{{ HTMLElement("table") }}
tabindexグローバル属性ブラウザーによる既定のタブオーダーを無効化して、指定した順序に従うようにします。
target{{ HTMLElement("a") }}, {{ HTMLElement("area") }}, {{ HTMLElement("base") }}, {{ HTMLElement("form") }}
titleグローバル属性要素の示す範囲のタイトル。PC ブラウザーでは、マウスオーバー時にツールチップとしてその属性値が表示される。
translateグローバル属性ページが翻訳版である場合、要素の属性値と子の Text ノードが翻訳されているか、変更せずにそのままであるかを指定します。
type{{ HTMLElement("button") }}, {{ HTMLElement("input") }}, {{ HTMLElement("command") }}, {{ HTMLElement("embed") }}, {{ HTMLElement("object") }}, {{ HTMLElement("script") }}, {{ HTMLElement("source") }}, {{ HTMLElement("style") }}, {{ HTMLElement("menu") }}要素の型を定義する。
usemap{{ HTMLElement("img") }}, {{ HTMLElement("input") }}, {{ HTMLElement("object") }}
value{{ HTMLElement("button") }}, {{ HTMLElement("data") }}, {{ HTMLElement("input") }}, {{ HTMLElement("li") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("option") }}, {{ HTMLElement("progress") }}, {{ HTMLElement("param") }}ページ読み込み時に要素で表示するデフォルト値を定義する。
width{{ HTMLElement("canvas") }}, {{ HTMLElement("embed") }}, {{ HTMLElement("iframe") }}, {{ HTMLElement("img") }}, {{ HTMLElement("input") }}, {{ HTMLElement("object") }}, {{ HTMLElement("video") }} +

ここに挙げられた要素に対して、要素の幅を指定します。

+ +
+

注: {{ HTMLElement("div") }} など他の要素については、これは古い属性であり、代わりに CSS の {{ Cssxref("width") }} プロパティを使用してください。

+
+
wrap{{ HTMLElement("textarea") }}テキストを折り返すかどうかを示します。
+ +

content 属性と IDL 属性

+ +

HTML では、ほとんどの属性に content 属性IDL (Interface Definition Language) 属性 の 2 つの側面があります。

+ +

content 属性は content (HTML コード) から設定する属性であり、 {{domxref("element.setAttribute()")}} や {{domxref("element.getAttribute()")}} を使用して設定あるいは取得できます。 content 属性は値として数値を想定するものであっても、常に文字列です。例えば content 属性を使用して {{HTMLElement("input")}} 要素の maxlength 属性に 42 を設定するには、その要素で setAttribute("maxlength", "42") を呼び出さなければなりません。

+ +

IDL 属性は JavaScript プロパティとしても知られています。これらは element.foo といった JavaScript プロパティを使用して読み書きします。IDL 属性は読み取り時に値を返すため基になる content 属性を使用 (ただし、変換するでしょう) したり、書き込み時に content 属性へ何らかの値を保存したりします。言い換えると、IDL 属性は content 属性を映し出します。

+ +

ほとんどの場合、IDL 属性は実際に使用する値として自身の値を返します。例えば {{HTMLElement("input")}} 要素の type 属性のデフォルト値は "text" であるので、input.type="foobar" を設定すると <input> 要素は (外見と動作が) text タイプになりますが、"type" content 属性の値は "foobar" になります。しかし、type IDL 属性は文字列 "text" を返します。

+ +

IDL 属性は常に文字列とは限りません。例えば input.maxlength は数値 (符号付き long) です。IDL 属性を使用するときは望ましい型の値を読み書きするので、input.maxlength は常に数値を返し、また input.maxlength を設定するときは数値を要求します。他の型で渡すと、標準的な JavaScript の型変換規則に従って自動的に数値へ変換されます。

+ +

IDL 属性は符号なし long、URL、論理値など他の型を反映することが可能です。残念ながら、属性に応じて IDL 属性が対応する content 属性と一体化して動作するための明確な規則や方法はありません。ほとんどの場合は仕様にある規則に従いますが、そうでない場合もあります。 HTML 仕様では可能な限り開発者にやさしいものにしようとしていますが、さまざまな理由 (たいていは歴史的な理由) により奇妙な動作になる属性 (例えば select.size) があり、実際どのように動作するかを理解するために仕様書を読むようにしましょう。

+ +

論理属性

+ +

一部のコンテンツ属性 (例えば required, readonly, disabled) は論理属性 (boolean attributes) と呼ばれています。論理属性は存在すれば、その値は true となり、存在しなければ、その値は false となります。

+ +

HTML5 では、論理属性に許されている値の制約を定義しています。属性が存在する場合は、値は空文字列 (属性の値が割り当てられないことがあります) または属性の正式名に ASCII で大文字・小文字まで一致する値のどちらかで、前後にホワイトスペースを含んではいけません。以下の例は論理属性をマークアップする正しい方法です。

+ +
<div itemscope> This is valid HTML but invalid XML. </div>
+<div itemscope=itemscope> This is also valid HTML but invalid XML. </div>
+<div itemscope=""> This is valid HTML and also valid XML. </div>
+<div itemscope="itemscope"> This is also valid HTML and XML, but perhaps a bit verbose. </div>
+ +

明確にするために、 "true" および "false" という値は論理属性では許可されていません。偽の値を表すには、属性ごと省略する必要があります。この制約により、いくつかのよくある誤解が明確になります。例えば checked="false" は、属性が存在するため、その要素の checked 属性が true であると解釈されます。

+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf