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 “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


Download files

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

Source Distribution

premailer-1.0.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file premailer-1.0.tar.gz.

File metadata

  • Download URL: premailer-1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for premailer-1.0.tar.gz
Algorithm Hash digest
SHA256 188b5bf1d029fe10e4f38b54f2fee4dfe6f58cdcd7480a710ab6cd8b58ab309b
MD5 08f31eb9ae5601ab7c5dd543ecd1e216
BLAKE2b-256 68c6f48656af0518b3cc2aabfa0b828bd81c147ba4dce273f09e256d0e4f3d64

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page