premailer now excludes pseudo selectors by default

27 May 2013   0 comments   Python, Web development

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!

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 keywords:
mincss "Clears the junk out of your CSS" 21 January 2013
setAttribute('style', ...) workaround for IE 08 January 2007
premailer.py - Transform CSS into line style attributes with lxml.html 11 July 2009
The awesomest way possible to serve your static stuff in Django with Nginx 24 March 2010
COPYFILE_DISABLE and python distutils in python 2.6 12 April 2014
Premailer on Python 3 08 October 2014
mincss in action - sample report from the wild 22 January 2013
premailer now with 100% test coverage 22 August 2014
This site is now 100% inline CSS and no bytes are wasted 05 March 2013
XHTML, HTML and CSS compressor 07 April 2004
How to use premailer as a command line script 13 July 2012
premailer now honours specificity 21 March 2013