Here’s how and why to specify image dimensions when uploading to the web using HTML code.
Here’s how and why to specify image dimensions when uploading to the web using HTML code
The first reason is that by specifying the dimensions, we can resize the image as we wish, always reducing it and never increasing it with HTML code.
The second reason is to communicate the dimensions of the image to be loaded to the browser, so that the browser struggles less when loading them and speeds up execution.
If you don’t know the image’s dimensions, just upload it to the browser, place the mouse over the image, right-click, and select “Properties” from the menu, where all the image’s information is contained.
We’ve already seen how to insert an image with HTML code, but let’s refresh our memory.
<img src="images/stones.gif">
Now let’s assign the width and height dimensions to the image, by inserting them in HTML:
<img src="images/stones.gif" width="50" height="50">
Through the width and height parameters, we have specified the dimensions of our image expressed in pixels. It is essential to indicate and specify the dimensions of the images you will be inserting on your web pages. You could also not do it, but I advise you to always indicate them to allow the browser to load images more quickly.
Pubblicato in HTML & CSS
Be the first to comment