Setting Width and Height

aspect_ratio
width & height Attributes
Control image dimensions in pixels
<img src="photo.jpg" width="300" height="200">
photo_size_select_large
Benefits
Reserves space before image loads, prevents layout shift
tips_and_updates Responsive Images
  • Use CSS for better control: max-width: 100%
  • Maintain aspect ratio to avoid distortion
  • Consider srcset for different screen sizes
  • Set only width or height to auto-scale the other dimension
HTML image attributes example
<img src="landscape.jpg" alt="Mountain landscape" width="600" height="400">