Conditional formatting for HTML Signatures in Outlook 2016+

牧云@^-^@ 提交于 2019-12-13 20:12:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!