premailer now excludes pseudo selectors by default

27 May 2013   0 comments   Python, Web development

Mind That Age!

This blog post is 4 years old! Most likely, its content is outdated. Especially if it's technical.

Powered by Fusion×

Thanks to Igor who emailed me and made me aware, you can't put pseudo classes in style attributes in HTML. I.e. this does not work:

<a href="#" style="color:pink :hover{color:red}">Sample Link</a>

See for yourself: Sample Link

Note how it does not become red when you hover over the link above.
This is what premailer used to do. Until yesterday.

BEFORE:

>>> from premailer import transform
>>> print transform('''
... <html>
... <style>
... a { color: pink }
... a:hover { color: red }
... </style>
... <a href="#">Sample Link</a>
... </html>
... ''')
<html><head><a href="#" style="{color:pink} :hover{color:red}">Sample Link</a></head></html>


AFTER:

>>> from premailer import transform
>>> print transform('''
... <html>
... <style>
... a { color: pink }
... a:hover { color: red }
... </style>
... <a href="#">Sample Link</a>
... </html>
... ''')
<html><head>
<style>a:hover {color:red}</style>
<a href="#" style="color:pink">Sample Link</a>
</head></html>


That's because the new default is exclude pseudo classes by default.

Thanks Igor for making me aware!

Follow @peterbe on Twitter

Comments

Thank you for posting a comment

Your email will never ever be published


Related posts

Previous:
What stumped me about AngularJS 12 May 2013
Next:
In Python you sort with a tuple 14 June 2013
Related by Keyword:
Ultrafast loading of CSS 01 September 2017
Premailer 3.0.0 - classes kept by default 07 June 2016
CSS Bloat Comparison 03 June 2016
How to no-mincss links with django-pipeline 03 February 2016
django-semanticui-form 14 September 2015
Related by Text:
premailer now honours specificity 21 March 2013
How to use premailer as a command line script 13 July 2012
Premailer 3.0.0 - classes kept by default 07 June 2016
How to no-mincss links with django-pipeline 03 February 2016
premailer.py - Transform CSS into line style attributes with lxml.html 11 July 2009