Depending on the situation and project requirements you can use one of this methods or both of them together.
Example 1
Use div tag with role and aria-label attributes:
<div role=”img” aria-label=”Description of the image” title=”Tooltip for users not using assistive technologies” style=”background-image: url(image.jpg);”></div>
Example 2
Use background image, but also have visually hidden <img> tag:
<div style=”background-image: url(image.jpg);”><img class=”hidden” src=”” alt=””></div>
Example 3
Use microdatas, for example:
<div itemscope itemtype=”http://schema.org/Article”>
<meta itemprop=”image” content=”bg.jpg”></meta>
<div style=”background-image:url(‘bg.jpg’)”></div>
</div>
Conclusion
HTML <img> tags should be used when it is a critical piece of accessible content, and consider speed, performance, and manipulation when deciding on what to do with an image used as a visual design enhancement.
If you need to choose between using an HTML <img> tag or a CSS background-image – just ask yourself a question: does this image help people in understanding my content better? If the answer is yes – use img tag. If – no – set it as a background image. After all – if both ways can provide you with the same visual result – you just need to define what has more sense in your situation.
Many businesses in Adelaide are beginning to utilise SEO as an integral part of their…
In this article, you will learn why marketing via text messages is vital to your…
Over the years, Google has introduced several new features to enable different aspects of digital…
Join us as we discuss how to get the most from some of the major…
As the organizations keeps on seeking new possibilities that can be leveraged to optimize their…
Instagram is associated with digital marketing activities that lend a hand to the business to…