DEV Community

Charity Parks
Charity Parks

Posted on

How to add an image to your website using HTML...

Adding images to your web page can really make it stand out. When you find the right image, it just pops! You can find images on such sites as www.istockphoto.com or www.gettyimages.com. You will want to create an 'images' folder to store them in.

You will need to use the <img> element and it must include two attributes:

  1. src : This tells the browser where your image is being stored
  2. alt : This is where you can add text to show in place of the image if for some reason the image fails to show up on your web page. For example, "Image of Company Logo". The <img> tag doesn't need a closing tag.

Your image is added like this:

<img src="images/dog.jpg" alt="A picture of a dog" />

You can add things like height and width to them by adding on to the above example.

<img src="images/dog.jpg" alt="A picture of a dog"
width="600" height="450" />

You can also add images by using CSS using background-image property. But thats for another day! Happy coding!

Top comments (0)