What is the difference between figure and image tag ?
<figure>
- The figure tag is used to semantically organize the content of images, videos, audios or even charts or tables, block of codes in the HTML document.
- <figure> tag is a container tag.
- This tag provides a container for content that is equivalent to a figure or diagram in a book.
- This tag is inline element.
- You can use the figure element in conjunction with the <figcaption> element to provide a caption for the contents of your figure element.
- It makes it easy for the machine to understand the code. Easy to get on search engines.
- The <figure> element itself may contain multiple other child elements be it a block of code, images, audios, video etc.
- The figure tag contains default alignment and styling.
<img>
- The image tag is used to add an image to an HTML page. <img> tag can only insert image.
- <img> tag is a void tag.
- The HTML <img> tag is used for embedding images into an HTML document.
- It is an inline element but when we specify width and height it becomes a block element.
- In image tag there’s no special tag for caption rather we can use <p> tag or <span> tag to add pseudo captions.
- It is difficult for machines to understand.
- The <img> tag can not have multiple elements inside it only images can be added in <img> tag.
- The image tag does not contain any default alignment and styling.