Skip to content
doubtly

2 answers

Set the width and height attributes of the <img> tag, or use CSS.

Using attributes (values in pixels):

<img src="photo.jpg" alt="Photo" width="400" height="300">

Using CSS:

<img src="photo.jpg" alt="Photo" style="width:400px; height:auto;">

Setting only the width with height:auto keeps the original proportions, so the image does not look stretched. Using width:100% makes the image fit the width of its container, which is useful for mobile-friendly pages.

Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.