问题
So, I'm trying to understand the conditional formatting in HTML email signatures within Outlook 2016 and above.
I have this short demo code:
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<!--[if mso]>
<p style="background: blue">
<![endif]-->
<p style="background: pink">TEST TEST TEST</p>
<!--[if mso]>
</p>
<![endif]-->
</body>
</html>
Which, by my logic, should change the background colour to blue, if the HTML is rendered within Outlook 2016.
However, it's pink.
Is my code incorrect logically? or is there something wrong with the conditional statement all together?
Do conditional statements even still work in Outlook?
[Edit] So, this seems to work, as far as setting the text blue, but I now can't get the text to be green elsewhere.
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<p style="background: pink">TEST TEST TEST</p>
<!--[if mso]>
<p style="background: blue">
<![endif]-->
<!--[if !mso]>
<p style="background: green">
<![endif]-->
Test Test Test 2
</p>
</body>
</html>
回答1:
Ok, so the condition, needs to be within the element that it's trying to change.
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<p style="background: pink">
<!--[if mso]>
<p style="background: blue">
<![endif]-->
Test Test Test
</p>
</body>
</html>```
来源:https://stackoverflow.com/questions/58208183/conditional-formatting-for-html-signatures-in-outlook-2016