Living Standard â Last Updated 1 September 2026
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, isSubtreeRoot, and oldAncestor are:
If isSubtreeRoot is true and oldAncestor is a picture element, then for each child of oldAncestor'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, isSubtreeRoot, and oldAncestor are:
If isSubtreeRoot is true and oldAncestor is a picture element, then for each child of oldAncestor'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ãŸãã¯controls屿§ããã€å ŽåïŒã€ã³ã¿ã©ã¯ãã£ãã³ã³ãã³ããsourceèŠçŽ ã®åŸã«ãpictureèŠçŽ ã®åãšããŠãalt â ç»åãå©çšäžå¯ã§ããå Žåã«äœ¿çšãã代çšããã¹ãsrc â ãªãœãŒã¹ã®ã¢ãã¬ã¹srcset â ç°ãªãç¶æ³ã§äœ¿çšããããã®ç»åãããšãã°ãé«è§£å床ãã£ã¹ãã¬ã€ãå°ããªã¢ãã¿ãŒããªã©ãsizes â ç°ãªãããŒãžã¬ã€ã¢ãŠãã®ç»åãµã€ãºcrossorigin â èŠçŽ ãçæå
ããŸããã èŠæ±ãåŠçããæ¹æ³usemap â 䜿çšããã€ã¡ãŒãžãããã®ååismap â ç»åããµãŒããŒåŽã€ã¡ãŒãžãããã§ãããã©ããcontrols â ãŠãŒã¶ãŒãšãŒãžã§ã³ãã®ã³ã³ãããŒã«ã衚瀺ãã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 , Reflect ] attribute boolean controls ;
[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èŠçŽ ã®ãã©ãŒã«ããã¯ã³ã³ãã³ãã§ãããïŒ
alt屿§ã®å€ã«é¢ããèŠä»¶ã¯ãåã
ã®ç¯ã§èª¬æãããã
å°ãªããšã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屿§ã¯ãsrcset屿§ã§ããã
ïŒå¹
èšè¿°åã䜿çšãããªãå ŽåïŒ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, isSubtreeRoot, and oldAncestor are:
If isSubtreeRoot is true and oldAncestor is a picture element, then count this as a relevant mutation for movedNode.
The img HTML element removing steps, given removedNode, oldAncestor, and isSubtreeRoot are:
If isSubtreeRoot is true and oldAncestor 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èŠçŽ ãšäžç·ã«äœ¿çšãããå Žåã«æ··ä¹±ããæ¯ãèãããããããããããªãã
controls屿§ã¯çåœå±æ§ã§ãããååšããå ŽåããŠãŒã¶ãŒãšãŒãžã§ã³ãããŠãŒã¶ãŒã«ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ãå
¬éããå¯èœæ§ãããããšã瀺ããalt屿§ãæããªãèŠçŽ ããŸãã¯alt屿§ã®å€ã空æååã§ããèŠçŽ ã«å¯ŸããŠã屿§ãæå®ããŠã¯ãªããªãã
If the controls attribute is present, the user agent may expose controls over the image (e.g., a control for fullscreen viewing). The specific controls provided are implementation-defined, and can be platform-specific or based on the user's preferences.
If the user agent exposes a user interface by displaying controls over the img element, then the user agent should suppress any user interaction events while the user agent is interacting with this interface.
Issue #12318 tracks the interaction between image controls and animated images. User agents should not expose animation controls for images before that issue is resolved.
imgèŠçŽ ã¯ã次å
屿§ããµããŒãããã
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.
loading IDL屿§ã¯ãæ¢ç¥ã®å€ã®ã¿ã«éå®ãããloadingã³ã³ãã³ã屿§ãåæ ããªããã°ãªããªãã
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.
該åœããå Žåãé©åãªåŒæ°ã§æž¡ãããå€ã«èšå®ãããwidthãšheight屿§ãæã€ãæ°ããimgèŠçŽ ãè¿ãã
To determine the dimensions of an img element image:
If image is being rendered, then return its rendered width and height, in CSS pixels. [CSS]
If image is available and has density-corrected natural width and height, then return its density-corrected natural width and height, in CSS pixels.
Return a width of 0 and a height of 0.
The width getter steps are to return the width of this's dimensions.
The height getter steps are to return the height of this's dimensions.
The naturalWidth and naturalHeight getter steps are:
If the image is not available, then return 0.
Return the respective component of the image's density-corrected natural width and height, in CSS pixels. [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 >