A question was sent to my personal email about embedding CSS in an HTML template and  I thought that it may be useful to this list as well. I remember a question or comment here about this...

The user was asking how to embed CSS in their HTML and have colors substituted so that they could be changed within Python. Below is a small example of doing this.

    <?xml version='1.0' encoding='utf-8'?>
    <?python
    main_color = "red"
    other_color = "blue"
    ?>
    <html xmlns="http://www.w3.org/1999/xhtml"
         xmlns:py="http://purl.org/kid/ns#">
    <head>
        <title>CSS Sample</title>
        <style type="text/css">
            body { background-color: $main_color; font-color: $other_color; }
        </style>
    </head>
    </html>

-- David

Reply via email to