For many images on your website, you may wish to use stock photos or images that you have come across on the internet. In my case, I have either used personal images that I have the rights to or have sourced some images from free stock photo websites. It is best to credit the photographers if you use other people's work. The websites that I have used most to populate my sites with images have been Pexels and Stockvault.
After downloading your images, it is good to have them in a web friendly format. Some image formats have large file sizes and can take a long time to load, creating a frustrating experience for your users. So unless you intend to recreate the internet experience of the early 2000s, you should convert your images into web friendly formats such as .webp. For this, I have found that Cloud Convert works wonderfully.
Image elements are self-closing and generally follow the form of:
<img src="filename.webp" alt="image description" width="200" height="200">
-
src="filename.webp"defines the source of the image; where to get it from. If it is saved in your project, this would be the file path of the image. If it is stored online on some image sharing website such as Imgur, you would need to put the url for the direct link here. -
alt="description"is the written description of the image. This serves 2 purposes. Firstly if, for any reason, the image fails to load, this text will be displayed instead so that the user can read what the image would have been. Secondly, this is used by screen readers to describe the image to users with visual impairments, allowing you to create a truly accessible experience for your users. -
width="200" height="200"specifies the height and width of your image. This is best done through linking with an external styling sheet so can be mostly ignored.