HTML email template i am sending to the Yahoo client does not have CSS applied to the <img>
elements:
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
.image1 {
width: 100px;
height: 100px;
border-radius: 50%;
}
.image2 {
width: 100px;
height: 50;
margin: 0 auto;
}
.container {
background: red;
}
</style>
</head>
<body>
<img src="someimage1.jpg" class="image1" />
<div class="container">
<img src="someimage2.jpg" class="image2" />
</div>
</body>
</html>
2
Answers
For the Yahoo client,
img
elements need to haveid
attributes with CSS that we want to apply.Solution:
I added same
id
names as theclass
and just added in the CSS that same CSS properties apply to them.NOTE:
I left classes present, just to be sure if some other client messes with
class
on some other elements:Elaboration
The issue was, that Yahoo client strips CSS that are referred in the
image1
andimage2
classes for<img>
elements. Not sure why, but this only happens for thisimg
tag.Most of the email clients transfer embedded CSS into inline, and for Yahoo, it seems they are not transferring onto
<img>
elements.Yes, you are right. You need to write inline CSS. And also for most email clients it is always recommended to write table-based html. And you also have to avoid a lot of CSS rules that doesn’t work for emails. Like here,
border-radius
will not work in Outlook. So when writing CSS you can also check what CSS property you can use for emails.