2 answers
<img src="demo.jpg" alt="Nature" style="width:500px;height:600px;">
codelikepro
· 19 Aug 2022
Report
Was this answer helpful?
Thanks for the feedback.
Sign up free to save answers and ask your own doubts
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?
Thanks for the feedback.
Sign up free to save answers and ask your own doubts
Your answer
Log in or create a free account to answer this question.