Closed kevinashaw closed 5 years ago
Based on my research this is one way. Is this the recommended method for yattag:
with tag('head'):
with tag('style'):
doc.asis('p {color:blue}')
with tag('html'):
with tag('body'):
line('p',"Hello world")
...
Yes, that would work here, but in general I'd rather use the text
method instead of asis
. That would ensure that a possible '<' or '&' character in your CSS instructions don't end up messing up the HTML structure of the document.
Actually, I rarely use <style>
tags. I prefer to put the CSS instructions in one or more separate files and use <link rel="stylesheet" href="mystyle.css">
.
@leforestier. Thank you. We are using HTML to format and publish reports. The reports needs to be self-contained with no external links. Hence, we need a way to embed all CSS formatting. The proposed method works well. Thanks!
How does one add CSS objects to HTML with yattag? A brief bit of sample code would help tremendously. My core goal is to redefine the
tag for a document that I need to be built with Python, and I would like to use CSS to define it. Thanks. -K