While modern browsers can figure out an image's size after it finishes loading, specifying the and height beforehand is a best practice for several performance and usability reasons:
: Explicitly stating the dimensions helps ensure the image doesn't appear distorted. For a image, the aspect ratio is approximately
: In modern web development, these attributes are often used alongside CSS ( max-width: 100%; height: auto; ) to ensure the image scales down correctly for mobile screens while still preserving the reserved space on desktop.
. Keeping this ratio consistent prevents the "stretched" look often seen when only one dimension is specified.