milkshakesoftware / PreMailer.Net

C# library that moves your stylesheets to inline style attributes, for maximum compatibility with E-mail clients.
http://milkshakesoftware.github.com/PreMailer.Net/
MIT License
652 stars 117 forks source link

!important being removed from non-inlined CSS #410

Open TopCoder02 opened 3 months ago

TopCoder02 commented 3 months ago

When using premailer and if the class matches a style, it removes !important on styles, that have nothing to do with the class being inlined.

I see issues in the past logged here where it says Outlook Ignores !important, that doesn't really seem the be the case anymore and many email clients support it now without issue. I also feel that in the style tag, itself, if the color was red !important it should be an optional if you want to transfer the !important it. Most use cases I think the answer will be "no", but I can see edge cases where you would want to keep it.

This:

 <style> 
 .test {
  color:red;
  }
  </style>
<body>
 <p class="test" style="font-weight: bold !important;">test</p>
</body>

Becomes this notice the !important was removed from the font-weight:

<body>
 <p class="test" style="color:red; font-weight: bold;">test</p>
</body>
martinnormark commented 3 months ago

Isn't this fine, since all styles are inlined? There should be no style block targeting the p tag?