Image Examples
Example Code
<img src="https://placehold.co/300x200" alt="Placeholder Image" width="300" height="200">
<img src="https://placehold.co/300x300" alt="Square Placeholder" loading="lazy">
<img src="https://placehold.co/150x150" alt="Small Placeholder" width="150" height="150">
HTML Image Tag & Attributes
<img>
The <img>
tag embeds an image in a webpage. It is a
self-closing tag that uses attributes to define the source and properties.
src
The src
attribute specifies the URL or file path of the image.
Example: src="image.jpg"
.
alt
The alt
attribute provides alternative text for accessibility
and when the image fails to load.
width
The width
attribute sets the display width of the image
(in pixels or %). Example: width="300"
.
height
The height
attribute sets the display height of the image.
Example: height="200"
.
loading
The loading
attribute defines how the image is loaded:
lazy
(load only when needed) or eager
(load immediately).