HTML Image Attributes
Images bring life to the web. The <img> tag relies entirely on its attributes to function correctly.
The Source (src)
The src attribute is mandatory. It contains the URL to the image file. If the browser cannot find the image at this address, it displays a broken image icon.
Alternative Text (alt)
The alt attribute provides a textual alternative. This is crucial for screen readers (accessibility) and for SEO. If the image fails to load, the alt text is displayed.
Dimensions & Loading
Always specify width and height to prevent layout shifts. Use loading="lazy" to defer loading off-screen images.
View Full Transcript+
This section contains the detailed transcript covering absolute vs relative paths for src, valid alt text strategies, and the importance of aspect ratio preservation.
