premailer now excludes pseudo selectors by default

27 May 2013   0 comments   Python, Web development

Mind That Age!

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

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

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:
Optimize DOM selector lookups by pre-warming by selectors' parents 11 February 2019
csso and django-pipeline 28 February 2018
CSS selector simplifier regular expression in JavaScript 20 December 2017
Ultrafast loading of CSS 01 September 2017
Premailer 3.0.0 - classes kept by default 07 June 2016