How to show a image in html page?

Use the <img src="image.jpg">image name</img>

I don't think the above is right, use the below instead.
Code:
<img src="http://example.com/folder/image.format" alt="image1" width="400" height="400" />
Note: I used an absolute url in the codes above. And the alt attribute holds the value of the alternate text to be displayed incase the image didn't load.
 
Last edited:
You don't need to put the width/height tags usually anymore, web-browsers can process that automatically, all you need is the img tag itself, which is:

<img src="IMAGE URL HERE" alt="RANDOM NAME THAT SHOWS WHEN HOVERING OVER THE IMAGE" />
 
It's best practice to still use the height and width tags as much as possible. What will still sometimes happen is if there are no dimensions specified, the browser will collapse the layout if the image cannot load. However if there are dimensions specified and the image cannot load, the browser will at least hold the space for the image, not causing the layout to break.
 
Please don't include the width and height attributes in an image tag. Doing this will force the image to display at that specific size, no matter what size device the page is being viewed on. Keep responsive design in mind. 400px X 400px is small on your widescreen monitor, and huge on your phone.
 
Back
Top