How do you use images in HTML and what are some of the attributes used to control their size and placement?

To use an image in HTML, you use the <img> element and specify the source of the image using the "src" attribute. The "src" attribute should contain the URL or file path of the image you want to use. Here is an example:
<img src="image.jpg">

You can control the size and placement of an image in HTML using various attributes, such as:

  • width and height : These attributes can be used to specify the width and height of the image in pixels.
  • <img src="image.jpg" width="200" height="100">
alt : The "alt" attribute can be used to provide alternative text for the image, which can be displayed if the image cannot be loaded or is being read by a screen reader.
<img src="image.jpg" alt="A beautiful sunset">

style : The "style" attribute can be used to specify the placement and size of an image using CSS.
<img src="image.jpg" style="width: 200px; height: 100px; float: right;">

class & id : The class and id attributes can be used to apply styles to an image using CSS.
<img src="image.jpg" class="my-image">
It's also important to note that the <img> element is self-closing and it does not have a closing tag.