[Fixed]-Keeping HTML in Django email templates DRY

1👍

Consider defining a CSS class and assigning this class to all the elements that need to be formatted.

template.css

 .MyEmailStyle {
    font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;
    font-size: 14px; 
    line-height: 1.6em; 
    font-weight: normal; 
    margin: 10px 0 10px; 
    padding: 0;
 }

main.html

<p class="MyEmailStyle">
    Hello John
</p>

As you can’t include external or internal CSS files in an email template, consider using this library.

👤navid

Leave a comment