Sometimes, we want to set the equivalent of the src attribute of an img tag in CSS.
In this article, we’ll look at how to set the equivalent of the src attribute of an img tag in CSS.
How to set the equivalent of the src attribute of an img tag in CSS?
To set the equivalent of the src attribute of an img tag in CSS, we set the content
CSS property.
For instance, we write
<img class="image" />
to add an img element.
Then we write
.image {
content: url("https://picsum.photos/200/300");
}
to set the content
attribute to the URL of the image we want to show.
Conclusion
To set the equivalent of the src attribute of an img tag in CSS, we set the content
CSS property.