Should I add the height and width to the img src tag?

Question

Should I add the height and width to the img src tag?

Answer

Yes. Adding the height and width attributes to your IMG SRC HTML tag allows the browser to properly size the images as the page is loading. Without these values the browser will not know how to properly size each image and will only be able to determine the size of the image after it has been loaded.

You'll notice web pages that do not have their image dimensions specified, since the overall size and layout of the page will change as the page is loaded. This will often confuse the user or distract them as they are trying to read the content on the page.

Additional information

  • Category
  • HTML Q&A
  • Solved?
  • Were you able to locate the answer to your question?