Skip to content

html

wybthon.html

Pythonic HTML element helpers that wrap the h() function.

Instead of writing::

h("div", {"class": "card", "on_click": handler}, h("p", {}, "Hello"))

you can write::

div(p("Hello"), class_name="card", on_click=handler)

Children are positional arguments, props are keyword arguments.

Prop name mapping:

  • class_nameclass (Python reserved word)
  • html_forfor (Python reserved word)
  • All other kwargs pass through unchanged.

Fragment(*args)

Group multiple children without adding extra DOM elements.

Unlike the previous <span style="display:contents"> approach, fragments now use comment-node markers and mount children directly into the parent container. This avoids polluting the DOM, breaking CSS selectors like :first-child, or affecting layout.

Can be called directly::

Fragment(child1, child2)

Or used as a component tag via h()::

h(Fragment, {}, child1, child2)