Images with img
The <img> element embeds an image resource. The src attribute identifies the image, while alt provides alternative text. Decorative images can use an empty alt="" so assistive technologies can ignore them.
Always Consider alt
Ask whether the image communicates information. If it does, describe that information; if it is purely decorative, an empty alt attribute is often appropriate.
Accessible Image
<img src="developer.jpg" alt="Developer working at a laptop" width="800" height="500">The alt text communicates the image's purpose. Explicit dimensions can help browsers reserve layout space before the image loads.
Key Takeaways
Meaningful images should have useful alternative text.
Decorative images can use alt="".
Knowledge Check
Which attribute provides alternative text for an image?