Living Standard — Last Updated 22 October 2025
picture要素Support in all current engines.
Support in all current engines.
source要素、その後に来る1つのimg要素、任意でスクリプトサポート要素と混合される。[Exposed =Window ]
interface HTMLPictureElement : HTMLElement {
[HTMLConstructor ] constructor ();
};
picture要素は、スクリーンピクセル密度、ビューポートサイズ、画像フォーマット、およびその他の要素を元にした、著者に宣言的にコントロールを許可するために、または画像が使用するためのリソースに関するユーザーエージェントに対するヒントを与えるために、ソースの含まれたimg要素に複数のソースを提供するコンテナーである。この要素は、要素の子を表す。
picture要素は、videoおよびaudio要素によく似た異なる何かである。それら要素のすべてがsource要素を含む一方で、source要素のsrc属性は、要素がpicture要素内でネストされる場合に意味を持たず、リソース選択アルゴリズムは異なる。同様に、picture要素自身は何も表示しない。要素は複数のURLから選択する要素を有効にする要素の含まれるimg要素にコンテキストを単に提供する。
source要素Support in all current engines.
Support in all current engines.
img要素の前の、picture要素の子として。track要素の前で、メディア要素の子として。type — 埋め込みリソースタイプmedia — 受け入れ可能なメディアsrc(audioまたはvideo内) — リソースのアドレスsrcset(pictureにおける) — 異なる状況で使用するための画像。たとえば、高解像度ディスプレイ、小さなモニター、など。sizes(pictureにおける) — 異なるページレイアウトの画像サイズwidth(pictureにおける) — 横の次元height(pictureにおける) — 縦の次元[Exposed =Window ]
interface HTMLSourceElement : HTMLElement {
[HTMLConstructor ] constructor ();
[CEReactions , ReflectURL ] attribute USVString src ;
[CEReactions , Reflect ] attribute DOMString type ;
[CEReactions , Reflect ] attribute USVString srcset ;
[CEReactions , Reflect ] attribute DOMString sizes ;
[CEReactions , Reflect ] attribute DOMString media ;
[CEReactions , Reflect ] attribute unsigned long width ;
[CEReactions , Reflect ] attribute unsigned long height ;
};
source要素は、著者にimg要素に対する複数の代替ソースセットまたはメディア要素に対する複数の代替メディアリソースの指定を許可する。この要素は、自分自身で何かを表すものではない。
type属性は存在してもよい。存在する場合、値は妥当なMIMEタイプ文字列でなければならない。
media属性は存在してもよい。存在する場合、値は妥当なメディアクエリーリストでなければならない。値が環境とマッチしない場合、ユーザーエージェントは次のsource要素にスキップする。
media属性は、メディア要素のリソース選択アルゴリズム中に一度だけ評価される。対照的に、picture要素を使用する場合、ユーザーエージェントは環境の変化に反応する。
要件の残りの部分は、親がpicture要素またはメディア要素であるかどうかによって異なる:
source要素の親がpicture要素であるsrcset属性は存在しなければならず、かつsrcset属性である。
source要素が選択される場合、srcset属性はソースセットの画像ソースに寄与する。
srcset属性が幅記述子を用いる任意の画像候補文字列を持つ場合、sizes属性も存在してもよい。さらに、後に続く兄弟img要素が自動サイズを許可しない場合、sizes属性が存在しなければならない。sizes属性はサイズ属性であり、source要素が選択されている場合、source sizeをsource setに提供する。
img要素が自動サイズを許可する場合、sizes属性は、前の兄弟source要素で省略できる。そのような場合は、autoを指定するのと同じである。
source要素は、次元属性をサポートする。img要素は、レンダリングの節で定義されるように、レンダリングされる次元およびアスペクト比を決定するために、img要素自身の属性の代わりに、source要素のwidthおよびheight属性を使用することができる。
type属性が与えられた種類をサポートしない場合に、次のsource要素にスキップするのをユーザーエージェントに可能にするために、この属性はソースセットで画像の種類を与える。
type属性が指定されない場合、ユーザーエージェントがフェッチする後で画像フォーマットをサポートしないならば、ユーザーエージェントは異なるsource要素を選択しない。
source要素が次の兄弟source要素または指定されるsrcset属性をもつimg要素を持つ場合、この要素は少なくとも次の1つを持たなければならない:
先頭および末尾のASCII空白を除去する後で、空文字列でなくかつASCII大文字・小文字不区別で文字列"all"に一致しないような値で指定されるmedia属性。
指定されるtype属性。
src属性は存在してはならない。
source要素の親がメディア要素であるsrc属性は、メディアリソースのURLを与える。値は、潜在的にスペースで囲まれた妥当な空でないURLでなければならない。この属性は存在しなければならない。
type属性は、この属性をフェッチする前に、このメディアリソースを再生できるかどうかをユーザーエージェントが判断するために、メディアリソースの型を示す。特定のMIMEタイプが定義するcodecsパラメーターは、リソースがエンコードされる方法を正確に指定する必要があるかもしれない。[RFC6381]
要素がvideoまたはaudio要素にすでに挿入されている場合、source要素のsrcまたはtype属性を動的に変更しても効果はない。再生している内容を変更するためには、使用可能なリソースの中から選択するcanPlayType()メソッドをおそらく利用して、直接メディア要素のsrc属性を単に使用する。一般に、文書が解析された後に手動でsource 要素を操作することは、不必要に複雑なアプローチとなる。
次のリストは、type属性でcodecs=MIMEパラメーターを使用する方法の例を示す。
< source src = 'video.mp4' type = 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"' > < source src = 'video.mp4' type = 'video/mp4; codecs="avc1.58A01E, mp4a.40.2"' > < source src = 'video.mp4' type = 'video/mp4; codecs="avc1.4D401E, mp4a.40.2"' > < source src = 'video.mp4' type = 'video/mp4; codecs="avc1.64001E, mp4a.40.2"' > < source src = 'video.mp4' type = 'video/mp4; codecs="mp4v.20.8, mp4a.40.2"' > < source src = 'video.mp4' type = 'video/mp4; codecs="mp4v.20.240, mp4a.40.2"' > < source src = 'video.3gp' type = 'video/3gpp; codecs="mp4v.20.8, samr"' > < source src = 'video.ogv' type = 'video/ogg; codecs="theora, vorbis"' > < source src = 'video.ogv' type = 'video/ogg; codecs="theora, speex"' > < source src = 'audio.ogg' type = 'audio/ogg; codecs=vorbis' > < source src = 'audio.spx' type = 'audio/ogg; codecs=speex' > < source src = 'audio.oga' type = 'audio/ogg; codecs=flac' > < source src = 'video.ogv' type = 'video/ogg; codecs="dirac, vorbis"' > The source HTML element insertion steps, given insertedNode, are:
Let parent be insertedNode's parent.
If parent is a media element that has no src attribute and whose networkState has the value NETWORK_EMPTY, then invoke that media element's resource selection algorithm.
If parent is a picture element, then for each child of parent's children, if child is an img element, then count this as a relevant mutation for child.
The source HTML element moving steps, given movedNode and oldParent, are:
If oldParent is a picture element, then for each child of oldParent's children, if child is an img element, then count this as a relevant mutation for child.
The source HTML element removing steps, given removedNode and oldParent, are:
If oldParent is a picture element, then for each child of oldParent's children, if child is an img element, then count this as a relevant mutation for child.
ユーザーエージェントがすべて提供されたメディアリソースをレンダリングすることができるかどうか、著者が確信できない場合、著者は最後のsource要素のフォールバック動作にerrorイベントをリッスンできる:
< script >
function fallback( video) {
// replace <video> with its contents
while ( video. hasChildNodes()) {
if ( video. firstChild instanceof HTMLSourceElement)
video. removeChild( video. firstChild);
else
video. parentNode. insertBefore( video. firstChild, video);
}
video. parentNode. removeChild( video);
}
</ script >
< video controls autoplay >
< source src = 'video.mp4' type = 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"' >
< source src = 'video.ogv' type = 'video/ogg; codecs="theora, vorbis"'
onerror = "fallback(parentNode)" >
...
</ video >
img要素Support in all current engines.
Support in all current engines.
Support in all current engines.
Support in all current engines.
Support in all current engines.
Support in all current engines.
Support in all current engines.
usemap属性をもつ場合:インタラクティブコンテンツ。source要素の後に、picture要素の子として。alt — 画像が利用不可である場合に使用する代用テキストsrc — リソースのアドレスsrcset — 異なる状況で使用するための画像。たとえば、高解像度ディスプレイ、小さなモニター、など。sizes — 異なるページレイアウトの画像サイズcrossorigin — 要素が生成元をまたいだ要求を処理する方法usemap — 使用するイメージマップの名前ismap — 画像がサーバー側イメージマップであるかどうかwidth — 横の次元height — 縦の次元referrerpolicy — 要素によって開始されたフェッチのためのリファラーポリシーdecoding — プレゼンテーションに対するにこの画像を処理する時に使用するデコーディングヒントloading — 読み込み延期を決定するときに使用fetchpriority — 要素によって開始されるフェッチの優先度を設定するalt属性を持つ場合:著者向け、実装者向け。[Exposed =Window ,
LegacyFactoryFunction =Image (optional unsigned long width , optional unsigned long height )]
interface HTMLImageElement : HTMLElement {
[HTMLConstructor ] constructor ();
[CEReactions , Reflect ] attribute DOMString alt ;
[CEReactions , ReflectURL ] attribute USVString src ;
[CEReactions , Reflect ] attribute USVString srcset ;
[CEReactions , Reflect ] attribute DOMString sizes ;
[CEReactions ] attribute DOMString ? crossOrigin ;
[CEReactions , Reflect ] attribute DOMString useMap ;
[CEReactions , Reflect ] attribute boolean isMap ;
[CEReactions , ReflectSetter ] attribute unsigned long width ;
[CEReactions , ReflectSetter ] attribute unsigned long height ;
readonly attribute unsigned long naturalWidth ;
readonly attribute unsigned long naturalHeight ;
readonly attribute boolean complete ;
readonly attribute USVString currentSrc ;
[CEReactions ] attribute DOMString referrerPolicy ;
[CEReactions ] attribute DOMString decoding ;
[CEReactions ] attribute DOMString loading ;
[CEReactions ] attribute DOMString fetchPriority ;
Promise <undefined > decode ();
// also has obsolete members
};
img要素は画像を表す。
img要素は、最初に要素自体に設定された次元属性ソースを持つ。
Support in all current engines.
Support in all current engines.
srcおよびsrcset属性、ならびに親がpicture要素である場合に任意の兄source要素のsrcset属性によって与えられる画像は、エンベティッドコンテンツである。alt属性の値は、画像を処理することができないまたは読み込みが無効である画像に対して、等価なコンテンツを提供する。(すなわち、img要素のフォールバックコンテンツである。)
少なくとも1つのsrcおよびsrcset属性が存在しなければならない。
src属性が存在する場合、この属性には、ページもスクリプトも作成されていない、非インタラクティブでオプションで、アニメーション化された画像リソースを参照する、潜在的にスペースで囲まれた妥当で空でないURLを含まなければならない。
上記の要件は、画像が静的ビットマップ(たとえばPNG、GIF、JPEG)、単一ページのベクター文書(単一ページのPDF、SVG文書要素を持つXMLファイル)、アニメーションビットマップ(APNG、アニメーションGIF)、アニメーションベクターグラフィックス(宣言型SMILアニメーションを使用するSVG文書要素を持つXMLファイル)などであることを意味する。しかし、これらの定義は、スクリプトを伴うSVGファイル、複数ページのPDFファイル、対話的なMNGファイル、HTML文書、プレーンテキスト文書などを排除する。[PNG] [GIF] [JPEG] [PDF] [XML] [APNG] [SVG] [MNG]
(幅記述子が使用されない場合)srcset属性およびsrc属性は、ソースセットに画像ソースに寄与する(どのsource要素も選択されなかった場合) 。
srcset属性が幅記述子を用いる任意の画像候補文字列を持つ場合、sizes属性も存在しなければならない。srcset属性が指定されておらず、loading属性がLazy状態の場合、sizes属性は値"auto"(ASCII大文字・小文字不区別)で指定できる。 sizes属性はサイズ属性であり、source sizeをsource setに提供する(source要素が選択されていない場合)。
img要素は、次の場合に自動サイズを許可する:
loading属性がLazy状態であり、かつ、sizes 属性の値が"auto"(ASCII大文字・小文字不区別)である、または"auto,"(ASCII大文字・小文字不区別)で始まる。Support in all current engines.
crossorigin属性はCORS設定属性である。その目的は、生成元をまたいだアクセスにcanvasとともに使用できるサードパーティのサイトからの画像を許可することである。
referrerpolicy属性は、リファラーポリシー属性である。その目的は、画像をフェッチするときに使用されるリファラーポリシーを設定することにある。[REFERRERPOLICY]
decoding属性は、この画像をデコードするための好ましい方法を示す。この属性は、存在する場合、画像デコーディングヒントでなければならない。この属性の欠損値のデフォルトと無効値のデフォルトは両方ともAuto状態である。
HTMLImageElement/fetchPriority
fetchpriorityは、フェッチ優先度属性である。その目的は、画像をフェッチするときに使用される優先順位を設定することである。
loading属性は、遅延読み込み属性である。その目的は、ビューポート外にある画像を読み込むためのポリシーを示すことである。
When the loading attribute's state is changed to the Eager state, the user agent must run these steps:
Let resumptionSteps be the img element's lazy load resumption steps.
If resumptionSteps is null, then return.
Set the img's lazy load resumption steps to null.
Invoke resumptionSteps.
< img src = "1.jpeg" alt = "1" >
< img src = "2.jpeg" loading = eager alt = "2" >
< img src = "3.jpeg" loading = lazy alt = "3" >
< div id = very-large ></ div > <!-- Everything after this div is below the viewport -->
< img src = "4.jpeg" alt = "4" >
< img src = "5.jpeg" loading = lazy alt = "5" >
上記の例では、画像は次のように読み込まれる:
1.jpeg, 2.jpeg, 4.jpeg画像は熱心に読み込まれ、ウィンドウの読み込みイベントを延期する。
3.jpegビューポート内にあるため、レイアウトがわかっているときに画像は読み込まれるが、ウィンドウの読み込みイベントは延期しない。
5.jpeg画像はビューポートに一度スクロールされるだけで読み込まれ、ウィンドウの読み込みイベントを延期しない。
開発者は、たとえCSSが画像の幅と高さのプロパティを設定しているとしても、遅延読み込みされた画像のwidthおよびheight属性を通して優先アスペクト比を指定し、画像の読み込み後にページレイアウトが移動するのを防ぐことを勧める。
The img HTML element insertion steps, given insertedNode, are:
If insertedNode's parent is a picture element, then, count this as a relevant mutation for insertedNode.
The img HTML element moving steps, given movedNode and oldParent, are:
If oldParent is a picture element, then, count this as a relevant mutation for movedNode.
The img HTML element removing steps, given removedNode and oldParent, are:
If oldParent is a picture element, then, count this as a relevant mutation for removedNode.
img要素は、レイアウトの手段として使用してはならない。特に、そのような画像はめったに意味を伝えることはなく、文書に有用なものを追加することもめったにないため、img要素は透明な画像を表示するために使用すべきでない。
What an img element represents depends on the src attribute and the alt attribute.
src attribute is set and the alt attribute is set to the empty stringThe image is either decorative or supplemental to the rest of the content, redundant with some other information in the document.
If the image is available and the user agent is configured to display that image, then the element represents the element's image data.
Otherwise, the element represents nothing, and may be omitted completely from the rendering. User agents may provide the user with a notification that an image is present but has been omitted from the rendering.
src attribute is set and the alt attribute is set to a value that isn't emptyThe image is a key part of the content; the alt attribute gives a textual equivalent or replacement for the image.
If the image is available and the user agent is configured to display that image, then the element represents the element's image data.
Otherwise, the element represents the text given by the alt attribute. User agents may provide the user with a notification that an image is present but has been omitted from the rendering.
src attribute is set and the alt attribute is notThe image might be a key part of the content, and there is no textual equivalent of the image available.
In a conforming document, the absence of the alt attribute indicates that the image is a key part of the content but that a textual replacement for the image was not available when the image was generated.
If the image is available and the user agent is configured to display that image, then the element represents the element's image data.
If the image has a src attribute whose value is the empty string, then the element represents nothing.
Otherwise, the user agent should display some sort of indicator that there is an image that is not being rendered, and may, if requested by the user, or if so configured, or when required to provide contextual information in response to navigation, provide caption information for the image, derived as follows:
If the image has a title attribute whose value is not the empty string, then return the value of that attribute.
If the image is a descendant of a figure element that has a child figcaption element, and, ignoring the figcaption element and its descendants, the figure element has no flow content descendants other than inter-element whitespace and the img element, then return the contents of the first such figcaption element.
Return nothing. (There is no caption information.)
src attribute is not set and either the alt attribute is set to the empty string or the alt attribute is not set at allThe element represents nothing.
The element represents the text given by the alt attribute.
The alt attribute does not represent advisory information. User agents must not present the contents of the alt attribute in the same way as content of the title attribute.
User agents may always provide the user with the option to display any image, or to prevent any image from being displayed. User agents may also apply heuristics to help the user make use of the image when the user is unable to see it, e.g. due to a visual disability or because they are using a text terminal with no graphics capabilities. Such heuristics could include, for instance, optical character recognition (OCR) of text found within the image.
While user agents are encouraged to repair cases of missing alt attributes, authors must not rely on such behavior. Requirements for providing text to act as an alternative for images are described in detail below.
The contents of img elements, if any, are ignored for the purposes of rendering.
usemap属性が存在する場合、画像が関連付けられたイメージマップを示すことができる。
href属性を持つa要素の子孫である要素で使用される場合、ismap属性は、要素がサーバーサイドのイメージマップへのアクセスを提供することによって、その存在を示す。これは、イベントが対応するa要素でどのように処理されるかに影響する。
ismap属性は真偽属性である。属性は、href属性を持つ祖先a要素を持たない要素に指定してはならない。
usemapおよびismap属性は、picture要素で指定されるmedia属性をもつsource要素と一緒に使用される場合に混乱する振る舞いをもたらすかもしれない。
Support in all current engines.
The crossOrigin IDL attribute must reflect the crossorigin content attribute, limited to only known values.
HTMLImageElement/referrerPolicy
Support in all current engines.
The referrerPolicy IDL attribute must reflect the referrerpolicy content attribute, limited to only known values.
Support in all current engines.
The decoding IDL attribute must reflect the decoding content attribute, limited to only known values.
Support in all current engines.
The loading IDL attribute must reflect the loading content attribute, limited to only known values.
The fetchPriority IDL attribute must reflect the fetchpriority content attribute, limited to only known values.
image.width [ = value ]Support in all current engines.
image.height [ = value ]Support in all current engines.
これらの属性は、実際のレンダリングされた画像の大きさ、または次元が未知である場合に0を返す。
対応するコンテンツ属性を変更するために、設定が可能である。
image.naturalWidthSupport in all current engines.
image.naturalHeightHTMLImageElement/naturalHeight
Support in all current engines.
これらの属性は、画像の自然次元を返す、または次元が不明な場合は0を返す。
image.completeSupport in all current engines.
画像が完全にダウンロードされている場合、または、何も画像が指定されない場合にtrueを返す。そうでなければ、falseを返す。
image.currentSrcSupport in all current engines.
画像の絶対URLを返す。
image.decode()Support in all current engines.
この方法は、ユーザーエージェントに画像をパラレルにデコードさせ、デコードが完了したときに実行されるプロミスを返す。
画像がデコードできない場合、プロミスは"EncodingError" DOMExceptionで拒否される。
image = new Image([ width [, height ] ])Support in all current engines.
The IDL attributes width and height must return the rendered width and height of the image, in CSS pixels, if the image is being rendered; or else the density-corrected natural width and height of the image, in CSS pixels, if the image has density-corrected natural width and height and is available but is not being rendered; or else 0, if the image is not available or does not have density-corrected natural width and height. [CSS]
The IDL attributes naturalWidth and naturalHeight must return the density-corrected natural width and height of the image, in CSS pixels, if the image has density-corrected natural width and height and is available, or else 0. [CSS]
Since the density-corrected natural width and height of an image take into account any orientation specified in its metadata, naturalWidth and naturalHeight reflect the dimensions after applying any rotation needed to correctly orient the image, regardless of the value of the 'image-orientation' property.
The complete getter steps are:
If any of the following are true:
both the src attribute and the srcset attribute are omitted;
the srcset attribute is omitted and the src attribute's value is the empty string;
the img element's current request's state is completely available and its pending request is null; or
the img element's current request's state is broken and its pending request is null,
then return true.
falseを返す。
The currentSrc IDL attribute must return the img element's current request's current URL.
The decode() method, when invoked, must perform the following steps:
Let promise be a new promise.
Queue a microtask to perform the following steps:
This is done because updating the image data takes place in a microtask as well. Thus, to make code such as
img. src = "stars.jpg" ;
img. decode();
properly decode stars.jpg, we need to delay any processing by one microtask.
Let global be this's relevant global object.
If any of the following are true:
this's node document is not fully active; or
this's current request's state is broken,
then reject promise with an "EncodingError" DOMException.
Otherwise, in parallel, wait for one of the following cases to occur, and perform the corresponding actions:
img element's node document stops being fully activeimg element's current request changes or is mutatedimg element's current request's state becomes brokenQueue a global task on the DOM manipulation task source with global to reject promise with an "EncodingError" DOMException.
img element's current request's state becomes completely availableDecode the image.
If decoding does not need to be performed for this image (for example because it is a vector graphic) or the decoding process completes successfully, then queue a global task on the DOM manipulation task source with global to resolve promise with undefined.
If decoding fails (for example due to invalid image data), then queue a global task on the DOM manipulation task source with global to reject promise with an "EncodingError" DOMException.
User agents should ensure that the decoded media data stays readily available until at least the end of the next successful update the rendering step in the event loop. This is an important part of the API contract, and should not be broken if at all possible. (Typically, this would only be violated in low-memory situations that require evicting decoded image data, or when the image is too large to keep in decoded form for this period of time.)
Animated images will become completely available only after all their frames are loaded. Thus, even though an implementation could decode the first frame before that point, the above steps will not do so, instead waiting until all frames are available.
Return promise.
decode()メソッドなしで、img要素をロードして表示するプロセスは次のようになる:
const img = new Image();
img. src = "nebula.jpg" ;
img. onload = () => {
document. body. appendChild( img);
};
img. onerror = () => {
document. body. appendChild( new Text( "Could not load the nebula :(" ));
};
しかし、画像がDOMに挿入された後に発生するペイントでは、メインスレッドで同期デコードが行われるため、フレームが著しく削除される可能性がある。
代わりに、これはdecode()メソッドを使用して書き換えることができる:
const img = new Image();
img. src = "nebula.jpg" ;
img. decode(). then(() => {
document. body. appendChild( img);
}). catch (() => {
document. body. appendChild( new Text( "Could not load the nebula :(" ));
});
この後者の形式は、ユーザーエージェントが画像をパラレルでデコードすることを可能にし、デコード処理が完了した後にのみ、DOMに挿入する(そして、それをペイントさせる)ことによって、元のフレームの欠落を回避する。
decode()メソッドは、デコードされた画像データが少なくとも1つのフレームで使用可能であることを保証しようとするため、requestAnimationFrame() APIと組み合わせることができる。つまり、すべてのDOMの変更をアニメーションフレームコールバックとして一緒にまとめるコーディングスタイルやフレームワークで使用することができる:
const container = document. querySelector( "#container" );
const { containerWidth, containerHeight } = computeDesiredSize();
requestAnimationFrame(() => {
container. style. width = containerWidth;
container. style. height = containerHeight;
});
// ...
const img = new Image();
img. src = "supernova.jpg" ;
img. decode(). then(() => {
requestAnimationFrame(() => container. appendChild( img));
});
A legacy factory function is provided for creating HTMLImageElement objects (in addition to the factory methods from DOM such as createElement()): Image(width, height). When invoked, the legacy factory function must perform the following steps:
Let document be the current global object's associated Document.
Let img be the result of creating an element given document, "img", and the HTML namespace.
If width is given, then set an attribute value for img using "width" and width.
If height is given, then set an attribute value for img using "height" and height.
Return img.
1つの画像は、コンテキストに応じて異なる適切な代替テキストを持つことができる。
次の場合のそれぞれにおいて、同じ画像を使用するが、altテキストは毎回異なる。画像は、スイスのジュネーブ州カルージュ自治体の紋章である。
ここでは、補足的なアイコンとして使用される:
< p > I lived in < img src = "carouge.svg" alt = "" > Carouge.</ p >
ここでは、町を表すアイコンとして使用される:
< p > Home town: < img src = "carouge.svg" alt = "Carouge" ></ p >
ここでは町でのテキストの一部として使用される:
< p > Carouge has a coat of arms.</ p >
< p >< img src = "carouge.svg" alt = "The coat of arms depicts a lion, sitting in front of a tree." ></ p >
< p > It is used as decoration all over the town.</ p >
ここでは代わりに代替物として、説明が与えられる場所で類似のテキストだけでなく画像もサポートするための方法として使用される:
< p > Carouge has a coat of arms.</ p >
< p >< img src = "carouge.svg" alt = "" ></ p >
< p > The coat of arms depicts a lion, sitting in front of a tree.
It is used as decoration all over the town.</ p >
ここでは、物語の一部として使用される:
< p > She picked up the folder and a piece of paper fell out.</ p >
< p >< img src = "carouge.svg" alt = "Shaped like a shield, the paper had a
red background, a green tree, and a yellow lion with its tongue
hanging out and whose tail was shaped like an S." ></ p >
< p > She stared at the folder. S! The answer she had been looking for all
this time was simply the letter S! How had she not seen that before? It all
came together now. The phone call where Hector had referred to a lion's tail,
the time Maria had stuck her tongue out...</ p >
ここでは、ある種の紋章であることのみで、どのような画像であるかを公表時点で未知であり、したがって、置換テキストが提供されず、title属性で、代わりに画像に対して簡単なキャプションが提供される:
< p > The last user to have uploaded a coat of arms uploaded this one:</ p >
< p >< img src = "last-uploaded-coat-of-arms.cgi" title = "User-uploaded coat of arms." ></ p >
理想的には、著者は、この場合ですら実際の置換テキストを提供するための方法を見つけるだろう。たとえば、前のユーザーを尋ねることによってなど。置換テキストを提供しないことは、画像を見ることができない人々、たとえば、視覚障害者のユーザー、または非常に低帯域幅の接続や従量課金、またはテキストのみのウェブブラウザーを使用することを余儀なくされているユーザーに対して文書の利用をより困難にする。
ここで、毎回別の適切な代替テキストをともなう、異なるコンテキストで使用したのと同じ写真を示す複数の例を次に示す。
< article >
< h1 > My cats</ h1 >
< h2 > Fluffy</ h2 >
< p > Fluffy is my favorite.</ p >
< img src = "fluffy.jpg" alt = "She likes playing with a ball of yarn." >
< p > She's just too cute.</ p >
< h2 > Miles</ h2 >
< p > My other cat, Miles just eats and sleeps.</ p >
</ article >
< article >
< h1 > Photography</ h1 >
< h2 > Shooting moving targets indoors</ h2 >
< p > The trick here is to know how to anticipate; to know at what speed and
what distance the subject will pass by.</ p >
< img src = "fluffy.jpg" alt = "A cat flying by, chasing a ball of yarn, can be
photographed quite nicely using this technique." >
< h2 > Nature by night</ h2 >
< p > To achieve this, you'll need either an extremely sensitive film, or
immense flash lights.</ p >
</ article >
< article >
< h1 > About me</ h1 >
< h2 > My pets</ h2 >
< p > I've got a cat named Fluffy and a dog named Miles.</ p >
< img src = "fluffy.jpg" alt = "Fluffy, my cat, tends to keep itself busy." >
< p > My dog Miles and I like go on long walks together.</ p >
< h2 > music</ h2 >
< p > After our walks, having emptied my mind, I like listening to Bach.</ p >
</ article >
< article >
< h1 > Fluffy and the Yarn</ h1 >
< p > Fluffy was a cat who liked to play with yarn. She also liked to jump.</ p >
< aside >< img src = "fluffy.jpg" alt = "" title = "Fluffy" ></ aside >
< p > She would play in the morning, she would play in the evening.</ p >
</ article >