back to home

HTML Images

  1. HTML images are defined with the < img > tag.
  2. The < img> tag is empty, it contains attributes only, and does not have a closing tag.
  3. The source file (src), alternative text (alt), width, and height are provided as attributes
  4. < img src="w3schools.jpg" alt="W3Schools.com" width="104" height="142" >
  5. The src attribute specifies the URL (web address) of the image
  6. The alt attribute provides an alternate text for an image, if the user for some reason cannot view it (because of slow connection, an error in the src attribute, or if the user uses a screen reader).The value of the alt attribute should describe the image. If a browser cannot find an image, it will display the value of the alt attribute. Note: The alt attribute is required. A web page will not validate correctly without it.
  7. You can use the style attribute to specify the width and height of an image. Alternatively, you can use the width and height attributes:
  8. HTML allows animated GIFs
    < img src="programming.gif" alt="Computer Man" style="width:48px;height:48px;">
  9. To use an image as a link, put the tag inside the tag
  10. Use the CSS float property to let the image float to the right or to the left of a text
    < p>< img src="https://picsum.photos/200/300" alt="random" style="float:right; width:42px; height:42px;"> The image will float to the right of the text.< /p>
    < p>< img src="https://picsum.photos/200/300" alt="random" style="float:left; width:42px; height:42px;"> The image will float to the left of the text.< /p>

    random The image will float to the right of the text.

    random The image will float to the left of the text.


  11. HTML Image Tags :