pyhtml5
A tiny Python library for writing HTML and CSS in code — with clear, full element names like Division, Paragraph, and Button. Render to a string in regular Python, or mount directly into the browser DOM when running under PyScript.
Why use it?
- Readable structure:
with Division(): Paragraph("Hello") - Works anywhere: strings in CPython, live DOM in PyScript
- Built-in CSS:
Stylesheet().rule(".card", padding="16px")
Install
pip install pyhtml5
Quick start
Build HTML (string)
from pyhtml5 import Division, Paragraph, Anchor, html_string
with Division(class_="card") as root:
Paragraph("Hello from pyhtml5! ")
Anchor("Read more", href="https://example.com", target="_blank")
print(html_string(root))
Use in PyScript (mount to the DOM)
from pyhtml5 import Division, Paragraph
with Division(class_="notice") as box:
Paragraph("Running inside PyScript!")
box.mount("#app") # or just box.mount() to append to <body>
CSS in code
from pyhtml5 import Stylesheet, css_string
with Stylesheet() as css:
css.rule(":root", color_scheme="light dark")
css.rule(".card", padding="16px", border="1px solid #ddd", border_radius="12px")
print(css_string(css)) # in PyScript, use css.mount() to inject a <style>
License
MIT License
See LICENSE for details.
Metadata
Release files for pyhtml5 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyhtml5-0.0.6.tar.gz | 14.6 kB | Without provenance | Details for pyhtml5-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyhtml5-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for pyhtml5-0.0.6-py3-none-any.whl |
Total release size: 30.8 kB
Release files / pyhtml5-0.0.6.tar.gz
| Download URL | pyhtml5-0.0.6.tar.gz |
|---|---|
| Size | 14.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
202b116b3d90bfa6aecfe81e5c871c021f02d2ffdb1131530e6119d843f9a97c
|
|
BLAKE2b-256 checksum How to use checksums |
806c49a51c68872769caf0133ec0ff5301ae8d47bad72b7b11707c89f6ad4fbd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Release files / pyhtml5-0.0.6-py3-none-any.whl
| Download URL | pyhtml5-0.0.6-py3-none-any.whl |
|---|---|
| Size | 16.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a849b6ddcc206e87f390c095144a8788603c7e907233ab3db8810f12563dd87f
|
|
BLAKE2b-256 checksum How to use checksums |
31df787e1c994918b6ad6d8bdd6481d130e8ac83335acda4f3fd7a3e6e55cf60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Security for pyhtml5 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.