You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes it is necessary to have inline styles include !important.
For example to remove link underlining in Windows 10 Mail.
However, it seems that Emogrifier drops the !important when inlining the styles. I understand this may be necessary for pseudo-class overrides to work, so it's probably a good default behaviour. But could there be an option added to allow it to be preserved?
The text was updated successfully, but these errors were encountered:
seb303
changed the title
!important should be included inline styles
!important should be preserved in inline styles
May 23, 2024
The !important is removed from inline styles because it is assumed all other rules have been applied inline, and therefore it is unncessariy, and could impact any additional CSS rules - it is impossible to override !important in an inline style.
Pseudo-class (and @media) rules currently don't work as well as they could - we are not adding !important so they are not overriding inline styles when perhaps they should. That is beyond the scope of this.
Would you be willing to create a PR for the option you propose, including tests?
That said, if Windows 10 Mail uses additional CSS with !important, could you not supply some additional CSS to beat it, with higher specificity and also !important, or is it junking any CSS you provide?
(Windows Mail and Microsoft Outlook I know are terrible, but telling people not to use them is not an option.)
I'm not sure I have the experience (or time at the moment) to create a PR & tests, sorry.
Regarding overriding the CSS in another way: I guess we could add back another <style> block after the HTML has been inlined, and put the !important style there. But in general we've reluctant to rely on mail clients honouring <style> blocks. It's much safer to inline everything if possible. I didn't test this with Outlook / Windows 10 Mail yet, but I will give it a try as a workaround for now.
Sometimes it is necessary to have inline styles include !important.
For example to remove link underlining in Windows 10 Mail.
However, it seems that Emogrifier drops the !important when inlining the styles. I understand this may be necessary for pseudo-class overrides to work, so it's probably a good default behaviour. But could there be an option added to allow it to be preserved?
The text was updated successfully, but these errors were encountered: