HTML Images tag is used to link images in a webpages.
<img> tag is used to link images.
This tag contains only src & alt attributes, it is an empty tag and does not have a closing tag.
src - Use to define the path of image.
alt - Use to define the alternate text of an image.
To add a background image on an HTML element, use the HTML style attribute and the CSS background-image property:
<p style="background-image: url('mickey-mouse.jpg'); width:100%; height:500px"> There is image in Background</p>
Try It »
In the above example, the background images going to repeat according to the space.
background-size property use to cover the background image.
background-repeat property use to stop repeating image in the background.
<p style="background-image: url('mickey-mouse.jpg'); background-repeat: no-repeat; background-size: cover; width:100%; height:500px"> There is image in Background</p>
Try It »
The HTML <picture> tag is used to display different pictures for different devices or screen sizes.
<h2>Picture Tag</h2>
<picture>
<source media="(min-width: 650px)" srcset="mickey-mouse.jpg">
<source media="(min-width: 465px)" srcset="donald-duck.jpg">
<img src="disney-logo.jpg" style="width:auto">
</picture>
<p>Resize the screen to see the effect. </p>
Try It »