Skip to main content

Turns CSS blocks into style attributes

Project description

Turns CSS blocks into style attributes

When you send HTML emails you can’t used style tags but instead you have to put inline style attributes on every element. So from this:

<html> <style type=”text/css”> p { color:red;} </style> <p>Hej</p> </html>

You want this:

<html> <p style=”color:red”>Hej</p> </html>

premailer does this. It parses an HTML page, looks up style blocks and parses the CSS. It then uses the lxml.html parser to modify the DOM tree of the page accordingly.

Turning relative URLs into absolute URLs

Another thing premailer can do for you is to turn relative URLs (e.g. “/some/page.html” into “”). It does this to all href and src attributes that don’t have a :// part in it. For example, turning this:

<html> <body> <a href=”/”>Home</a> <a href=”page.html”>Page</a> <a href=””>External</a> <img src=”/folder/”>Folder</a> </body> </html>

Into this:

<html> <body> <a href=””>Home</a> <a href=””>Page</a> <a href=””>External</a> <img src=””>Folder</a> </body> </html>

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
premailer-1.0.tar.gz (4.3 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page