# premailer **Repository Path**: mirrors_HubSpot/premailer ## Basic Information - **Project Name**: premailer - **Description**: Turns CSS blocks into style attributes - **Primary Language**: Unknown - **License**: BSD-3-Clause - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-24 - **Last Updated**: 2026-02-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README premailer ========= 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:
Hej
You want this:Hej
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. Getting started --------------- If you havena't already done so, install `premailer` first: $ pip install premailer Next, the most basic use is to use the shortcut function, like this: >>> from premailer import transform >>> print transform(""" ... ... ...Hej
... ... """)Hej
For more advanced options, check out the code of the `Premailer` class and all its options in its constructor. 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: Home Page External