{"action":"created","issue":{"url":"https://api.github.com/repos/peterbe/premailer/issues/150","labels_url":"https://api.github.com/repos/peterbe/premailer/issues/150/labels{/name}","comments_url":"https://api.github.com/repos/peterbe/premailer/issues/150/comments","events_url":"https://api.github.com/repos/peterbe/premailer/issues/150/events","html_url":"https://github.com/peterbe/premailer/issues/150","id":118877899,"number":150,"title":"!important not inlined with style attribute","user":{"login":"mblayman","id":636865,"avatar_url":"https://avatars.githubusercontent.com/u/636865?v=3","gravatar_id":"","url":"https://api.github.com/users/mblayman","html_url":"https://github.com/mblayman","followers_url":"https://api.github.com/users/mblayman/followers","following_url":"https://api.github.com/users/mblayman/following{/other_user}","gists_url":"https://api.github.com/users/mblayman/gists{/gist_id}","starred_url":"https://api.github.com/users/mblayman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mblayman/subscriptions","organizations_url":"https://api.github.com/users/mblayman/orgs","repos_url":"https://api.github.com/users/mblayman/repos","events_url":"https://api.github.com/users/mblayman/events{/privacy}","received_events_url":"https://api.github.com/users/mblayman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-25T16:49:49Z","updated_at":"2015-11-30T13:03:06Z","closed_at":null,"body":"Hi, thanks for premailer! It's very useful.\r\n\r\nI am working on some responsive emails and I have observed that premailer does not include the `!important` attribute when it inlines CSS into a `style` attribute on a tag.\r\n\r\nI see that this issue comment (https://github.com/peterbe/premailer/issues/133#issuecomment-143356964) mentions that `!important` should not be valid on inlined styles. That's probably true. Unfortunately, Gmail will not respect certain inline styles without the !important attribute included.\r\n\r\nI work for a company in the education space and Google tools for education (and thereby Gmail) are hugely popular. Because Gmail does not respect things like `display:none` without inlining as `display: none !important`, the results appear incorrect and affect a large percentage of our user base.\r\n\r\nGmail has made making responsive emails a total pain so I recognize that this issue is not really a fault in premailer. If premailer cannot inline `!important` because of its HTML validity, I understand. I'd love to help patch the issue to get this working for my use case. Any pointers on where to look in the source would be very appreciated. I'd submit a PR with my results in case others are interested.\r\n\r\nFor completeness, I've included an example of the lack of inlined `!important`.\r\n\r\n```python\r\nimport premailer\r\n\r\ncss = '.hide { display:none !important; margin: 5px; }'\r\nhtml = '<div class=\"hide\">I mean it.</div>'\r\np = premailer.Premailer(\r\n    html, css_text=css, strip_important=False, keep_style_tags=True,\r\n    remove_classes=False)\r\nprint p.transform()\r\n```\r\n```bash\r\n$ python test.py\r\n<html>\r\n<head><style type=\"text/css\">.hide { display:none !important; margin: 5px; }</style></head>\r\n<body><div class=\"hide\" style=\"display:none; margin:5px\">I mean it.</div></body>\r\n</html>\r\n```"},"comment":{"url":"https://api.github.com/repos/peterbe/premailer/issues/comments/160621981","html_url":"https://github.com/peterbe/premailer/issues/150#issuecomment-160621981","issue_url":"https://api.github.com/repos/peterbe/premailer/issues/150","id":160621981,"user":{"login":"peterbe","id":26739,"avatar_url":"https://avatars.githubusercontent.com/u/26739?v=3","gravatar_id":"","url":"https://api.github.com/users/peterbe","html_url":"https://github.com/peterbe","followers_url":"https://api.github.com/users/peterbe/followers","following_url":"https://api.github.com/users/peterbe/following{/other_user}","gists_url":"https://api.github.com/users/peterbe/gists{/gist_id}","starred_url":"https://api.github.com/users/peterbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterbe/subscriptions","organizations_url":"https://api.github.com/users/peterbe/orgs","repos_url":"https://api.github.com/users/peterbe/repos","events_url":"https://api.github.com/users/peterbe/events{/privacy}","received_events_url":"https://api.github.com/users/peterbe/received_events","type":"User","site_admin":false},"created_at":"2015-11-30T13:03:06Z","updated_at":"2015-11-30T13:03:06Z","body":"@mblayman So you're stuck between a rock and a hard place. Either you hack for the sake of Gmail or you make it work in Outlook. (Thanks @elidickinson!)\r\n\r\nAre there no better ways to make responsive emails? If so, that's a bummer. \r\n\r\nMy advice would be to add your own little hacks to the generated output. For now. E.g.\r\n```\r\nprint p.transform().replace('display:none;', 'display:none !important')\r\n```"}}