Image, Media, and Embedded Content Attributes
Media elements often depend heavily on attributes. This chapter groups the attributes used with images, audio, video, picture sources, and embedded content.
Image Attributes
Tag:
<img>
Important attributes:
srcaltwidthheightloadingsrcsetsizesdecoding
Possible loading values:
lazyeager
Possible decoding values:
autosyncasync
Figure-Related Tags
Tags:
<figure><figcaption>
These usually rely mostly on global attributes, but they are valuable when pairing media with descriptions.
Audio and Video Attributes
Tags:
<audio><video>
Important attributes:
srccontrolsautoplaymutedlooppreloadposterfor<video>playsinlinefor<video>
Possible preload values:
nonemetadataauto
Source and Track Attributes
Tags:
<source><track>
Important attributes:
srctypemediasrcsetkindsrclanglabeldefault
Possible kind values on <track>:
captionssubtitlesdescriptionschaptersmetadata
Embedded Content Tags
Tags:
<iframe><embed><object>
Important <iframe> attributes:
srctitlewidthheightloadingallowsandboxreferrerpolicy
Common loading values:
lazyeager
Example:
<iframe
src="https://example.com/embed"
title="Map preview"
width="600"
height="400"
loading="lazy"
sandbox="allow-scripts allow-same-origin">
</iframe>
Why These Attributes Matter
They affect:
- performance
- accessibility
- responsive behavior
- browser compatibility
- security