Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

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 “http://www.peterbe.com/some/page.html”). 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="http://crosstips.org">External</a>
<img src="/folder/">Folder</a>
</body>
</html>

Into this:

<html>
<body>
<a href="http://www.peterbe.com/">Home</a>
<a href="http://www.peterbe.com/page.html">Page</a>
<a href="http://crosstips.org">External</a>
<img src="http://www.peterbe.com/folder/">Folder</a>
</body>
</html>

Project details


Release history Release notifications

History Node

3.2.0

History Node

3.1.1

History Node

3.1.0

History Node

3.0.1

History Node

3.0.0

History Node

2.11.0

History Node

2.10.1

History Node

2.10.0

History Node

2.9.8

History Node

2.9.7

History Node

2.9.6

History Node

2.9.5

History Node

2.9.4

History Node

2.9.3

History Node

2.9.2

History Node

2.9.1

History Node

2.9.0

History Node

2.8.4

History Node

2.8.3

History Node

2.8.2

History Node

2.8.1

History Node

2.8.0

History Node

2.7.0

History Node

2.6.0

History Node

2.5.1

History Node

2.5.0

History Node

2.1.4

History Node

2.1.3

History Node

2.1.2

History Node

2.1.1

History Node

2.1.0

History Node

2.0.2

History Node

2.0.1

History Node

2.0.0

History Node

1.13

History Node

1.12

History Node

1.11

History Node

1.10

History Node

1.9

History Node

1.8

History Node

1.7

History Node

1.5.0

History Node

1.5

History Node

1.4.1

History Node

1.4.0

This version
History Node

1.4

History Node

1.3.0

History Node

1.3

History Node

1.2.3

History Node

1.2.2

History Node

1.2.1

History Node

1.2.0

History Node

1.2

History Node

1.1

History Node

1.0

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.4.tar.gz (4.8 kB) Copy SHA256 hash SHA256 Source None Jul 28, 2009

Supported by

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