Html
HTML & web
HTML element trees for BEAM SSR and shared views. Html.Events handlers are inert on the server (stripped from markup) and become real listeners after the JS client hydrates. Common tags (div, span, h1, a, ul, li, form, input, button, table, ...) and void tags (br, hr, img, ...) are available. Document-shell tags (html, head, body, title, style, meta, ...) live in Html.Document. Use main_ for the HTML main element so it does not clash with a module's main value.
Types
Html
type Html msg = HtmlAn HTML node parameterized by a message type (unused on the server).
Examples
welcome : Html msg
welcome =
node "p" [] [ text "hi" ]Values
text
text : String -> Html msgA text node.
Examples
text "hello"node
node : String -> List (Attribute msg) -> List (Html msg) -> Html msgA custom element by tag name.
Examples
node "div" [] [ text "hi" ]map
map : (a -> b) -> Html a -> Html bRemap the message type of an HTML tree.
Examples
map Never (text "x")toString
toString : Html msg -> StringRender HTML to a fragment string (no document wrapper).
Examples
toString (text "hi")toDocument
toDocument : Html msg -> StringRender a full HTML document string.
Examples
toDocument (node "p" [] [ text "hi" ])