--- name: hlive-hhtml description: >- Build HLive page markup with the hhtml package (github.com/SamHennessy/hlive/hhtml) — typed, autocompleting Go builders for HTML5 tags and attributes (Div, Button, A, Input, Class, Href, ...). Use when writing or editing HLive page/component markup, when you see the `. "github.com/SamHennessy/hlive/hhtml"` dot-import, or when choosing between hhtml builders and the raw l.T/l.C primitives. --- # Building markup with hhtml `hhtml` is the **preferred way to write HLive markup**. Instead of passing tag and attribute names as strings to `l.T`/`l.C`, you call typed Go functions — `Div(...)`, `Button(...)`, `Class("...")`, `Href("...")` — so you get editor autocomplete, no string typos, and embedded docs for each tag. ## Import idiom hhtml is designed for a **dot import**, used alongside the core package: ```go import ( l "github.com/SamHennessy/hlive" . "github.com/SamHennessy/hlive/hhtml" ) ``` The dot import lets you write `Div(...)` instead of `hhtml.Div(...)`. Behavior (events, state, render control) still comes from the `l` package — hhtml is markup only. ## Tag builders Every HTML5 tag has a builder with the signature: ```go func TagName(elements ...any) hlive.Adder ``` Capitalized tag name → function: `Html`, `Head`, `Body`, `Title`, `Meta`, `Link`, `Div`, `Span`, `P`, `H1`–`H6`, `A`, `Nav`, `Header`, `Footer`, `Aside`, `Main`, `Section`, `Article`, `Ul`/`Ol`/`Li`, `Form`, `Input`, `Button`, `Label`, `Select`/`Option`, `Textarea`, `Table`/`Thead`/`Tbody`/`Tr`/`Td`/`Th`, `Img`, `Script`, `Style`, and ~100 more. ```go Div(Class("card"), H1("Hello"), P("Welcome to ", A(Href("/docs"), "the docs"), "."), ) ``` A builder returns the `hlive.Adder` interface (written `l.Adder` with the conventional `l` alias) — the **same type** `l.T`/`l.C` return — so hhtml tags drop straight into `page.DOM().Body().Add(...)` and mix freely with raw `l.T`/`l.C` calls. ## Attribute functions Every attribute has a function with the signature: ```go func AttrName(value string) *hlive.Attribute ``` e.g. `Class`, `Id`, `Href`, `Src`, `Type`, `Value`, `Name`, `Placeholder`, `Rel`, `Charset`, `Content`, `For`. Pass them as elements: ```go Input(Type("text"), Name("email"), Placeholder("you@example.com"), Id("email")) Link(Rel("stylesheet"), Href("/assets/main.css")) ``` ### Collision rule — the `Attr` suffix When a tag and an attribute share a name, the **tag keeps the clean name** and the **attribute gets an `Attr` suffix**: | Clean name (tag) | Attribute function | | --- | --- | | `Title(...)` → `