0
Html <img> background
Is it possible to add a background-image to an img-tag? I tried like this: <img src = "imageOne.png" style = "height: 500px; width: 250px; background-image: imageTwo.jpg; opacity: 0.5;" /> It didn't get a background at all. Please note that imageOne and imageTwo are only example names, not the real ones.
3 Antworten
+ 1
This might be a concept to revisit later, but...
Most of the time, backgrounds are for aesthetics, so it's better to put them in the stylesheet as suggested in the prior post.
If a background image also happens to have semantic value (adds meaningful content), then consider leaving it in the HTML file in an img tag.
More on what to weigh here:
https://stackoverflow.com/questions/492809/when-to-use-img-vs-css-background-image
0
OK, thank you everyone, I didn't know that url() was necessary🤦
I simply wrote the images name...