Skip to content

olton/html

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Mar 18, 2025
b4f3852 · Mar 18, 2025

History

17 Commits
Mar 18, 2025
Mar 18, 2025
Mar 18, 2025
Mar 18, 2025
Jul 29, 2022
Jul 29, 2022
Feb 16, 2025
Mar 18, 2025
Mar 18, 2025
Mar 18, 2025
Jun 13, 2024
Feb 23, 2024

Repository files navigation

html

Create HTML pages in pure JavaScript!

Install

npm i @olton/html

of use from CDN:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@olton/html@latest">

Using

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="path-to/html.js"></script>
</head>
<body>

<script>
    ((() => {
        htmljs.extract()
        const body = document.querySelector("body")
        const root = document.createElement("main")
        body.appendChild(root)
        root.innerHTML = div(
            h1("Header"),
            form(
                label("Label", {class: "class1"}),
                input({type: "text", value:"123", data:{role: "input"}}),
                hr(),
                div(
                    button("Ok", {events: {onclick: "alert('Click Button')"}}),
                    button("Cancel", {type: "button"}),
                    {class: "actions"}
                )    
            )
        )
    })())
</script>
</body>
</html>

About

Create HTML pages in JavaScript! Including all standard components.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published