I am reading and taking notes on the HTML specifications for 100 days as part of #The100DayProject. Read the initial intent/backstory. I am a Microsoft employee but all opinions, comments, etc on this site are my own. I do not speak on behalf of my employer, and thus no comments should be taken as representative of Microsoft's official opinion of the spec. Subsections not listed below were read without comment.
Currently reading 4.7 Embedded content
UAs = User agents = Browsers, etc.
img element, contd.
Semantics of an
img element, as determined by how
alt attributes are set:
altis an empty string: image is decorative or redundant with its surrounding contents. If the UA does a request and finds the image source is not available, it can choose not to render this image (and can give the user notice that it didn’t render). I suppose that would be a “broken image” icon.
altis a non-empty string: this image is an important part of content. The
altvalue should be a descriptor useful enough that the user would know what should have displayed there, if the image didn’t load—or if a user was browsing with a screen reader.
altis not: “no textual equivalent of the image available.” If the image isn’t available in this case, the UA can choose to show that there’s an image here not being rendered. It can also try and grab caption information for the end user: if the
imgis a descendent of a
figureand the only text info in that
figureis the contents of
figcaption, the UA can use the
figcaptioncontents as this image’s caption.
altare set, the
imgelement doesn’t represent anything.
srcis not set, but
altis, the elements represents the
altattribute doesn’t store “advisory information”, as you might with the
If you try to add any content to an
imgelement, it will be ignored.
usemapon the element shows that the image has an image map.
ismapset on a descendent of an
aelement (which in turn has its
hrefattribute set), shows that the “element provides access to a server-side image map.” Is boolean and should only be used on elements that match this context.
IDL dimension attributes:
heightreturn as rendered dimensions if the image is being rendered visually; intrinsic width and height if it’s not be rendered to a “visual medium”; 0 if the image is unavailable.
naturalHeightreturn the intrinsic dimensions if the image is available, otherwise 0. I’m a bit shaky on what intrinsic actually means. Where is this grabbed from? Attributes set directly on the element? Something else?
Some conditions here for when the
complete attribute would return true.