| Pattern | Example | Output |
|---|---|---|
| Basic tag | p("hello") |
<p>hello</p> |
| Attribute | a("link", href="#") |
<a href="#">link</a> |
| class keyword | div(class_="box") |
<div class="box"></div> |
| Boolean attr | input_(disabled=True) |
<input disabled> |
| Nesting | ul(li("a"), li("b")) |
Indented HTML tree |
| Chain | div().add(p("hi")).attr(id="x") |
Fluent builder |
| style() helper | style(font_size="16px") |
font-size: 16px; |
| Render | render_page(html(...)) |
Full page with DOCTYPE |
| Write to file | to_file(page, "index.html") |
Saves to disk |
| Raw HTML | Raw("<!-- comment -->") |
Passthrough, no wrapper |