The img element in HTML


 Add images to your website:

  • You can add images to your web pages by using the img element and pointing to a specific image URL using the src attribute.
  • The basic form of the img element is:

      • <img src ="image URL" alt ="text message">

  • Note img element is self-closing,i.e., it does not have a closing tag like other HTML elements.
  • All img elements must have an alt attribute.
  • The alt attribute is used to place some text in it to improve readers' accessibility and is displayed if the image fails to load.
  • Note if the image is perfectly decorative, using an empty alt attribute is best practice.
  • Ideally, the alt attribute should not contain special characters and should be minimally used if required.
  • The finalized code for the img element is:

  • <img src="http://www.canva.com/images" alt="this is a platrform for building images of your choice">

No comments:

Post a Comment