h

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 6 Imported by: 0

README

h

A fast, type-safe HTML generator for Go.

Features

  • Auto-escaping - Strings are HTML-escaped automatically for security
  • Type-safe - Compile-time checking of your HTML structure
  • Zero dependencies - Pure Go standard library
  • Fast - Minimal allocations, direct writer output
  • Composable - Build complex layouts from simple components
  • HTMX support - Type-safe htmx attributes and embedded library via hx subpackage

Installation

go get github.com/assaidy/h

Quick Start

package main

import (
    "os"

    "github.com/assaidy/h"
)

func main() {
    page := h.Empty(
        h.DoctypeHTML(),
        h.Html(h.KV{h.AttrLang: "en"},
            h.Head(
                h.Title("My Page"),
            ),
            h.Body(
                h.H1("Hello, World!"),
                h.P("Auto-escaped: <script>alert('xss')</script>"),
            ),
        ),
    )
    
    if err := page.Render(os.Stdout); err != nil {
        panic(err)
    }
}

Usage

Basic Elements
// Strings are auto-escaped
h.Div("Hello", " ", "World")  // <div>Hello World</div>

h.P("<script>alert('xss')</script>")
// <p>&lt;script&gt;alert(&#39;xss&#39;)&lt;/script&gt;</p>

// Raw HTML (not escaped. use with caution)
h.Div(h.RawHTML("<svg>...</svg>")) // <svg>...</svg>

// Numbers and booleans are auto-converted
h.P("Count: ", 42)           // <p>Count: 42</p>
h.P("Active: ", true)        // <p>Active: true</p>
Attributes
// Use type-safe attribute constants from h package
h.Div(h.KV{h.AttrClass: "container", h.AttrID: "main"}, "Content")
// <div class="container" id="main">Content</div>

// Common attributes
h.Div(h.KV{h.AttrClass: "box", h.AttrStyle: "color: red", h.AttrTitle: "Tooltip"}, "Content")
h.Html(h.KV{h.AttrLang: "en"}, ...) // <html lang="en">

// Input attributes
h.Input(h.KV{
    h.AttrType:        h.InputTypeText,
    h.AttrName:        "username",
    h.AttrPlaceholder: "Enter username",
    h.AttrRequired:    true,
    h.AttrAutofocus:   true,
})
Common Attribute Types
  • h.AttrClass, h.AttrID, h.AttrStyle, h.AttrTitle, h.AttrLang, h.AttrDir, h.AttrHidden, h.AttrTabindex
  • h.AttrHref, h.AttrRel, h.AttrTarget, h.AttrDownload
  • h.AttrSrc, h.AttrSrcset, h.AttrAlt, h.AttrWidth, h.AttrHeight, h.AttrLoading
  • h.AttrAction, h.AttrMethod, h.AttrEnctype, h.AttrNovalidate
  • h.AttrName, h.AttrValue, h.AttrPlaceholder, h.AttrRequired, h.AttrDisabled, h.AttrReadonly
  • h.AttrType, h.AttrMin, h.AttrMax, h.AttrMinlength, h.AttrMaxlength, h.AttrPattern
  • h.AttrSrc, h.AttrAsync, h.AttrDefer, h.AttrCrossorigin, h.AttrIntegrity
  • and more...
Conditional Rendering
// Show element only if condition is true
h.If(isLoggedIn, h.Div("Welcome back!"))

// Choose between two options
h.IfElse(isAdmin, h.Div("Admin"), h.Div("User"))
Lists and Iteration
items := []string{"Apple", "Banana"}

// Map over slice
h.Ul(
    h.MapSlice(items, func(item string) h.Node {
        return h.Li(item)
    }),
)

// Repeat N times
h.Div(
    h.Repeat(3, func() h.Node {
        return h.P("Repeated")
    }),
)
Custom Layout
package components

import (
    "github.com/assaidy/h"
)

func layout(title string, children ...h.Node) h.Node {
    return h.Empty(
        h.DoctypeHTML(),
        h.Html(
            h.Head(
                h.Title(title),
                h.Meta(h.KV{h.AttrCharset: "UTF-8"}),
                h.Link(h.KV{h.AttrRel: h.RelStylesheet, h.AttrHref: "/style.css"}),
            ),
            h.Body(
                h.Nav(
                    h.A(h.KV{h.AttrHref: "/"}, "Home"),
                    h.A(h.KV{h.AttrHref: "/about"}, "About"),
                ),
                h.Main(children...),
            ),
        ),
    )
}

Usage:

h.Empty(
    layout("My Page",
        h.H1("Welcome"),
        h.P("Content here"),
    ),
)
With Tailwindcss
h.Div(h.KV{h.AttrClass: "bg-gray-100 min-h-screen p-8"},
    h.Div(h.KV{h.AttrClass: "max-w-4xl mx-auto"},
        h.H1(h.KV{h.AttrClass: "text-4xl font-bold text-gray-800"}, "Title"),
        h.P(h.KV{h.AttrClass: "text-gray-600 mt-2"}, "Description"),
        h.Button(h.KV{h.AttrClass: "px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"},
            "Click Me",
        ),
    ),
)
With HTMX

The hx subpackage provides type-safe htmx attributes and events:

import "github.com/assaidy/h/hx"

// Include htmx library in your head
h.Head(hx.Script())

// HTMX button with type-safe attributes
h.Button(h.KV{
    hx.AttrGet:      "/api/users",
    hx.AttrTarget:   "#users-list",
    hx.AttrSwap:     hx.SwapOuterHTML,
    hx.On(hx.Click): "console.log('Loading users...')",
    h.AttrClass:     "px-4 py-2 bg-blue-500 text-white rounded",
},
    "Load Users",
)

// HTMX form with events
h.Form(h.KV{
    hx.AttrPost:                "/api/submit",
    hx.AttrTarget:              "#result",
    hx.AttrSwap:                hx.SwapInnerHTML,
    hx.On(hx.HtmxAfterRequest): "handleResponse(event)",
},
    h.Input(h.KV{
        h.AttrType:  h.InputTypeText,
        h.AttrName:  "message",
        h.AttrClass: "border rounded px-3 py-2",
    }),
    h.Button(h.KV{h.AttrType: h.InputTypeSubmit}, "Submit"),
)
Available Attributes
  • hx.AttrGet, hx.AttrPost, hx.AttrPut, hx.AttrPatch, hx.AttrDelete - HTTP methods
  • hx.AttrTrigger - Event trigger
  • hx.AttrTarget - Target element for swap
  • hx.AttrSwap - Swap method (use with hx.Swap* constants)
  • hx.AttrSelect, hx.AttrSelectOob, hx.AttrSwapOob - Selectors
  • hx.AttrIndicator, hx.AttrConfirm, hx.AttrBoost - UX helpers
  • hx.AttrHeaders, hx.AttrVals, hx.AttrVars, hx.AttrParams - Data
  • hx.AttrSync, hx.AttrExt, hx.AttrPushURL, hx.AttrReplaceURL - Advanced
  • hx.AttrHistory, hx.AttrHistoryElt, hx.AttrValidate - History & validation
  • hx.AttrEncoding, hx.AttrInclude, hx.AttrDisinherit, hx.AttrInherit - Advanced
Swap Values
  • hx.SwapInnerHTML, hx.SwapOuterHTML - Replace content/element
  • hx.SwapBeforeBegin, hx.SwapAfterBegin, hx.SwapBeforeEnd, hx.SwapAfterEnd - Insert positions
  • hx.SwapDelete, hx.SwapNone - Special behaviors
DOM Events

Standard browser events: hx.Click, hx.Load, hx.Submit, hx.Change, hx.Keydown, hx.Keyup, hx.Focus, hx.Blur, hx.Mouseover, hx.Mouseout, etc.

HTMX Events

All htmx lifecycle events: hx.HtmxAfterRequest, hx.HtmxBeforeRequest, hx.HtmxConfigRequest, hx.HtmxLoad, hx.HtmxAfterSwap, hx.HtmxBeforeSwap, etc.

Complete Example
package main

import (
    "os"

    "github.com/assaidy/h"
    "github.com/assaidy/h/hx"
)

func main() {
    page := h.Empty(
        h.DoctypeHTML(),
        h.Html(h.KV{h.AttrLang: "en"},
            h.Head(
                h.Title("Dashboard"),
                h.Script(h.KV{h.AttrSrc: "https://cdn.tailwindcss.com"}),
                hx.Script(), // Include htmx library
            ),
            h.Body(h.KV{h.AttrClass: "bg-gray-100 p-8"},
                h.Div(h.KV{h.AttrClass: "max-w-2xl mx-auto"},
                    h.H1(h.KV{h.AttrClass: "text-3xl font-bold mb-4"}, "Dashboard"),

                    // HTMX-powered user list that loads dynamically
                    h.Div(h.KV{h.AttrID: "users-list"},
                        h.Button(h.KV{
                            hx.AttrGet:       "/api/users",
                            hx.AttrTarget:    "#users-list",
                            hx.AttrSwap:      hx.SwapOuterHTML,
                            hx.AttrIndicator: "#loading",
                            h.AttrClass:      "px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600",
                        },
                            "Load Users",
                        ),
                        h.Div(h.KV{h.AttrID: "loading", h.AttrClass: "hidden"}, "Loading..."),
                    ),

                    // HTMX form with validation and events
                    h.Form(h.KV{
                        hx.AttrPost:                 "/api/users",
                        hx.AttrTarget:               "#users-list",
                        hx.AttrSwap:                 hx.SwapAfterBegin,
                        hx.On(hx.HtmxBeforeRequest): "this.reset()",
                    },
                        h.KV{h.AttrClass: "mt-6 space-y-4"},
                        h.Input(h.KV{
                            h.AttrType:        h.InputTypeText,
                            h.AttrName:        "name",
                            h.AttrPlaceholder: "Enter name",
                            h.AttrClass:       "w-full px-3 py-2 border rounded",
                            hx.AttrValidate:   "true",
                        }),
                        h.Button(h.KV{
                            h.AttrType:  h.InputTypeSubmit,
                            h.AttrClass: "px-4 py-2 bg-green-500 text-white rounded hover:bg-green-600",
                        },
                            "Add User",
                        ),
                    ),
                ),
            ),
        ),
    )

    if err := page.Render(os.Stdout); err != nil {
        panic(err)
    }
}

Documentation

Index

Constants

View Source
const (
	// AttrClass is a space-separated list of CSS class names for the element.
	AttrClass = "class"
	// AttrID is the unique identifier for the element (must be unique within the document).
	AttrID = "id"
	// AttrStyle contains inline CSS styling declarations for the element.
	AttrStyle = "style"
	// AttrTitle provides advisory information about the element, often displayed as a tooltip.
	AttrTitle = "title"
	// AttrLang defines the primary language for the element's contents.
	AttrLang = "lang"
	// AttrDir indicates the directionality of the element's text content (ltr, rtl, or auto).
	AttrDir = "dir"
	// AttrHidden indicates that the element is not yet relevant or is no longer relevant.
	AttrHidden = "hidden"
	// AttrTabindex specifies whether the element is focusable and its position in tab order.
	AttrTabindex = "tabindex"
	// AttrType specifies the type of some element (e.g., script, input, button, object, source).
	AttrType = "type"
	// AttrHref specifies the URL of the linked resource.
	AttrHref = "href"
	// AttrRel defines the relationship between the current document and the linked resource.
	AttrRel = "rel"
	// AttrTarget specifies where to display the linked resource (_blank, _self, _parent, _top).
	AttrTarget = "target"
	// AttrHreflang indicates the language of the linked resource.
	AttrHreflang = "hreflang"
	// AttrDownload indicates that the link should be downloaded rather than navigated to.
	AttrDownload = "download"
	// AttrSrc specifies the URL of the media resource.
	AttrSrc = "src"
	// AttrSrcset defines multiple image sources for responsive images.
	AttrSrcset = "srcset"
	// AttrSizes specifies image widths for selecting the appropriate source.
	AttrSizes = "sizes"
	// AttrAlt provides alternative text for images.
	AttrAlt = "alt"
	// AttrWidth specifies the display width in pixels.
	AttrWidth = "width"
	// AttrHeight specifies the display height in pixels.
	AttrHeight = "height"
	// AttrLoading controls whether the browser should lazy-load the image.
	AttrLoading = "loading"
	// AttrDecoding provides a hint to the browser for decoding the image.
	AttrDecoding = "decoding"
	// AttrAction specifies the URL for form submission.
	AttrAction = "action"
	// AttrMethod specifies the HTTP method (get, post, dialog).
	AttrMethod = "method"
	// AttrEnctype specifies the encoding type for form data.
	AttrEnctype = "enctype"
	// AttrNovalidate disables form validation on submission.
	AttrNovalidate = "novalidate"
	// AttrName specifies the name of the input element, submitted with form data.
	AttrName = "name"
	// AttrValue specifies the initial value of the input element.
	AttrValue = "value"
	// AttrPlaceholder provides a hint to the user about what to enter.
	AttrPlaceholder = "placeholder"
	// AttrRequired indicates the user must fill in a value before submitting.
	AttrRequired = "required"
	// AttrDisabled indicates the element is disabled and cannot be interacted with.
	AttrDisabled = "disabled"
	// AttrReadonly indicates the element is not editable but can be focused.
	AttrReadonly = "readonly"
	// AttrChecked indicates whether a checkbox or radio button is selected.
	AttrChecked = "checked"
	// AttrSelected indicates whether an option in a select element is selected.
	AttrSelected = "selected"
	// AttrMultiple allows multiple values to be selected.
	AttrMultiple = "multiple"
	// AttrAutofocus indicates the element should be focused when the page loads.
	AttrAutofocus = "autofocus"
	// AttrAutocomplete hints to browsers whether to autofill the field.
	AttrAutocomplete = "autocomplete"
	// AttrPattern specifies a regular expression for validating input.
	AttrPattern = "pattern"
	// AttrMin specifies the minimum value allowed.
	AttrMin = "min"
	// AttrMax specifies the maximum value allowed.
	AttrMax = "max"
	// AttrStep specifies the increment/decrement step for numeric inputs.
	AttrStep = "step"
	// AttrMinlength specifies the minimum number of characters required.
	AttrMinlength = "minlength"
	// AttrMaxlength specifies the maximum number of characters allowed.
	AttrMaxlength = "maxlength"
	// AttrSize specifies the width of the input element in characters.
	AttrSize = "size"
	// AttrAsync executes the script asynchronously (non-blocking).
	AttrAsync = "async"
	// AttrDefer defers execution until HTML parsing completes.
	AttrDefer = "defer"
	// AttrNonce is a cryptographic nonce for Content Security Policy.
	AttrNonce = "nonce"
	// AttrCrossorigin specifies how to handle CORS requests.
	AttrCrossorigin = "crossorigin"
	// AttrIntegrity provides a hash to verify script integrity.
	AttrIntegrity = "integrity"
	// AttrNomodule prevents execution in ES module-supporting browsers.
	AttrNomodule = "nomodule"
	// AttrReferrerpolicy specifies the referrer policy for fetch.
	AttrReferrerpolicy = "referrerpolicy"
	// AttrCharset declares the character encoding for the document.
	AttrCharset = "charset"
	// AttrContent contains the value for the metadata.
	AttrContent = "content"
	// AttrHttpEquiv defines a pragma directive equivalent to an HTTP header.
	AttrHttpEquiv = "http-equiv"
	// AttrColspan specifies the number of columns a cell should span.
	AttrColspan = "colspan"
	// AttrRowspan specifies the number of rows a cell should span.
	AttrRowspan = "rowspan"
	// AttrHeaders associates header cells with data cells for accessibility.
	AttrHeaders = "headers"
	// AttrScope defines whether a header cell is for a row, column, or group.
	AttrScope = "scope"
	// AttrSpan specifies the number of columns in a colgroup.
	AttrSpan = "span"
	// AttrSrcdoc specifies the HTML content to embed inline.
	AttrSrcdoc = "srcdoc"
	// AttrSandbox applies extra restrictions on the iframe's content.
	AttrSandbox = "sandbox"
	// AttrAllow specifies a feature policy for the iframe.
	AttrAllow = "allow"
	// AttrCsp enforces Content Security Policy on the embedded content.
	AttrCsp = "csp"
)

Variables

This section is empty.

Functions

func IfElse

func IfElse[T any](condition bool, result, alternative T) T

IfElse returns the appropriate value based on a boolean condition.

This generic function is useful for inline conditional expressions in builder-style code where you need to choose between two values without breaking the chain of method calls.

Example:

div := Div(KV{"class": IfElse(isActive, "active", "inactive")})

Body(
	IfElse(isAdmin,
		Div("Admin content"),
		P("Regular user content"),
	),
)

func Render

func Render(w io.Writer, node Node) error

Render writes the HTML representation of a Node to the provided io.Writer.

This is a convenience function that makes it suitable for writing directly to files, HTTP responses, or other output streams.

Example:

err := Render(os.Stdout, Div("Hello"))
// Outputs: <div>Hello</div>

Types

type CrossoriginValue

type CrossoriginValue = string

CrossoriginValue represents valid values for the crossorigin attribute.

const (
	// CrossoriginAnonymous sends CORS request without credentials.
	CrossoriginAnonymous CrossoriginValue = "anonymous"
	// CrossoriginUseCredentials sends CORS request with credentials.
	CrossoriginUseCredentials CrossoriginValue = "use-credentials"
)

type DecodingValue

type DecodingValue = string

DecodingValue represents valid values for the decoding attribute.

const (
	// DecodingSync decodes synchronously, blocking other content.
	DecodingSync DecodingValue = "sync"
	// DecodingAsync decodes asynchronously to prevent blocking.
	DecodingAsync DecodingValue = "async"
	// DecodingAuto lets the browser decide (default).
	DecodingAuto DecodingValue = "auto"
)

type Element

type Element struct {
	Tag      string      // HTML tag name
	IsVoid   bool        // Whether the tag is self-closing (e.g., <br>, <img>)
	Attrs    []attribute // HTML attributes as key-value pairs
	Children []Node      // Child nodes
}

Element represents an HTML element with its attributes and children.

func (Element) Render

func (me Element) Render(w io.Writer) error

Render generates the HTML for the element and its children to the provided writer.

type EnctypeValue

type EnctypeValue = string

EnctypeValue represents valid encoding types for forms.

const (
	// EnctypeURLencoded encodes as key-value pairs (default).
	EnctypeURLencoded EnctypeValue = "application/x-www-form-urlencoded"
	// EnctypeMultipart encodes as multipart MIME (for file uploads).
	EnctypeMultipart EnctypeValue = "multipart/form-data"
	// EnctypePlain sends as plain text without encoding.
	EnctypePlain EnctypeValue = "text/plain"
)

type InputTypeValue

type InputTypeValue = string

InputTypeValue represents valid values for the type attribute of input elements.

const (
	// InputTypeText is a single-line text field (default).
	InputTypeText InputTypeValue = "text"
	// InputTypePassword obscures entered text.
	InputTypePassword InputTypeValue = "password"
	// InputTypeEmail is for email addresses with validation.
	InputTypeEmail InputTypeValue = "email"
	// InputTypeTel is for telephone numbers.
	InputTypeTel InputTypeValue = "tel"
	// InputTypeUrl is for URLs with validation.
	InputTypeUrl InputTypeValue = "url"
	// InputTypeNumber is for numeric values with validation.
	InputTypeNumber InputTypeValue = "number"
	// InputTypeSearch is for search queries.
	InputTypeSearch InputTypeValue = "search"
	// InputTypeDate is for dates (year, month, day).
	InputTypeDate InputTypeValue = "date"
	// InputTypeDatetimeLocal is for date and time without timezone.
	InputTypeDatetimeLocal InputTypeValue = "datetime-local"
	// InputTypeMonth is for month and year.
	InputTypeMonth InputTypeValue = "month"
	// InputTypeWeek is for week and year.
	InputTypeWeek InputTypeValue = "week"
	// InputTypeTime is for time values (hours and minutes).
	InputTypeTime InputTypeValue = "time"
	// InputTypeCheckbox allows multiple selections.
	InputTypeCheckbox InputTypeValue = "checkbox"
	// InputTypeRadio allows single selection from a group.
	InputTypeRadio InputTypeValue = "radio"
	// InputTypeFile allows selecting one or more files.
	InputTypeFile InputTypeValue = "file"
	// InputTypeSubmit submits the form.
	InputTypeSubmit InputTypeValue = "submit"
	// InputTypeReset resets the form to defaults.
	InputTypeReset InputTypeValue = "reset"
	// InputTypeButton is a button with no default behavior.
	InputTypeButton InputTypeValue = "button"
	// InputTypeHidden is an invisible input holding data.
	InputTypeHidden InputTypeValue = "hidden"
	// InputTypeImage is a graphical submit button.
	InputTypeImage InputTypeValue = "image"
	// InputTypeColor is for selecting colors.
	InputTypeColor InputTypeValue = "color"
	// InputTypeRange is for numeric values using a slider.
	InputTypeRange InputTypeValue = "range"
)

type KV

type KV map[string]any

KV represents a key-value map for HTML attributes.

The value type must be either string or bool:

  • string: Attribute will have the format key="value" (HTML-escaped)
  • bool: If true, attribute appears as key (valueless). If false, attribute is omitted.
  • any other type triggers an error during rendering.

Example:

KV{"class": "container", "hidden": true, "disabled": false}
// Renders: class="container" hidden

type LoadingValue

type LoadingValue = string

LoadingValue represents valid values for the loading attribute.

const (
	// LoadingEager loads the resource immediately (default).
	LoadingEager LoadingValue = "eager"
	// LoadingLazy defers loading until the resource is near the viewport.
	LoadingLazy LoadingValue = "lazy"
)

type MethodValue

type MethodValue = string

MethodValue represents valid HTTP methods for forms.

const (
	// MethodGet appends form data to the URL (default).
	MethodGet MethodValue = "get"
	// MethodPost sends form data in the request body.
	MethodPost MethodValue = "post"
	// MethodDialog closes the dialog and returns values.
	MethodDialog MethodValue = "dialog"
)

type Node

type Node interface {
	Render(io.Writer) error
}

Node represents any renderable HTML element or text content.

The Node interface is the core abstraction that allows both HTML elements and text content to be treated uniformly when building and rendering HTML trees. All elements created by the factory functions (Div(), P(), Svg(), etc.) implement this interface.

Example:

var node Node = Div("Hello")
err := node.Render(os.Stdout)

func A

func A(args ...any) Node

A creates hyperlinks to other web pages, files, locations within the same page, or anything else a URL can address.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a

func Abbr

func Abbr(args ...any) Node

Abbr represents an abbreviation.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/abbr

func Address

func Address(args ...any) Node

Address indicates contact information for a person or organization.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/address

func Area

func Area(attrs ...KV) Node

Area defines an area inside an image map that has predefined clickable areas. An image map allows geometric areas on an image to be associated with hyperlink.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/area

func Article

func Article(args ...any) Node

Article creates an article element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/article

func Aside

func Aside(args ...any) Node

Aside creates an aside element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/aside

func Audio

func Audio(args ...any) Node

Audio is used to embed sound content in documents. It may contain one or more audio sources, represented using the src attribute or the source element: the browser will choose the most suitable one. It can also be the destination for streamed media, using a MediaStream.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/audio

func B

func B(args ...any) Node

B draws attention to text without conveying importance.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/b

func Base

func Base(attrs ...KV) Node

Base specifies the base URL and default browsing context for relative URLs.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/base

func Bdi

func Bdi(args ...any) Node

Bdi isolates text for bidirectional text formatting.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/bdi

func Bdo

func Bdo(args ...any) Node

Bdo overrides the current text direction.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/bdo

func Blockquote

func Blockquote(args ...any) Node

Blockquote represents a section quoted from another source.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/blockquote

func Body

func Body(args ...any) Node

Body represents the content of an HTML document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/body

func Br

func Br(attrs ...KV) Node

Br produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division of lines is significant.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/br

func Button

func Button(args ...any) Node

Button is an interactive element activated by a user with a mouse, keyboard, finger, voice command, or other assistive technology. Once activated, it performs an action, such as submitting a form or opening a dialog.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button

func Canvas

func Canvas(args ...any) Node

Canvas is a container element to use with either the canvas scripting API or the WebGL API to draw graphics and animations.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/canvas

func Caption

func Caption(args ...any) Node

Caption specifies the caption (or title) of a table.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/caption

func Cite

func Cite(args ...any) Node

Cite marks the title of a creative work.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/cite

func Code

func Code(args ...any) Node

Code displays its contents styled as computer code.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/code

func Col

func Col(attrs ...KV) Node

Col defines one or more columns in a column group represented by its implicit or explicit parent &lt;colgroup&gt; element. The &lt;col&gt; element is only valid as a child of a &lt;colgroup&gt; element that has no span attribute defined.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/col

func Colgroup

func Colgroup(args ...any) Node

Colgroup defines a group of columns within a table.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/colgroup

func Data

func Data(args ...any) Node

Data links content with a machine-readable translation.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/data

func Datalist

func Datalist(args ...any) Node

Datalist contains a set of &lt;option&gt; elements that represent the permissible or recommended options available to choose from within other controls.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/datalist

func Dd

func Dd(args ...any) Node

Dd provides the description, definition, or value for the preceding term.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dd

func Del

func Del(args ...any) Node

Del represents a range of text that has been deleted from a document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/del

func Details

func Details(args ...any) Node

Details creates a disclosure widget in which information is visible only when the widget is toggled into an "open" state. A summary or label must be provided using the &lt;summary&gt; element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/details

func Dfn

func Dfn(args ...any) Node

Dfn indicates the defining instance of a term.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dfn

func Dialog

func Dialog(args ...any) Node

Dialog represents a dialog box or other interactive component, such as a dismissible alert, inspector, or subwindow.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dialog

func Div

func Div(args ...any) Node

Div is the generic container for flow content.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/div

func Dl

func Dl(args ...any) Node

Dl represents a description list.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dl

func DoctypeHTML

func DoctypeHTML() Node

DoctypeHTML creates the <!DOCTYPE html> element.

https://developer.mozilla.org/en-US/docs/Glossary/Doctype

func Dt

func Dt(args ...any) Node

Dt specifies a term in a description or definition list.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dt

func Em

func Em(args ...any) Node

Em marks text with emphasis.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/em

func Embed

func Embed(attrs ...KV) Node

Embed embeds external content at the specified point in the document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/embed

func Empty

func Empty(args ...any) Node

Empty creates an empty element (no tag).

func Fencedframe

func Fencedframe(args ...any) Node

Fencedframe represents a nested browsing context, like &lt;iframe&gt; but with more native privacy features built in.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/fencedframe

func Fieldset

func Fieldset(args ...any) Node

Fieldset is used to group several controls as well as labels (&lt;label&gt;) within a web form.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/fieldset

func Figcaption

func Figcaption(args ...any) Node

Figcaption represents a caption or legend for the contents of its parent figure element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/figcaption

func Figure

func Figure(args ...any) Node

Figure represents self-contained content with an optional caption.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/figure

func Footer(args ...any) Node

Footer creates a footer element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/footer

func Form

func Form(args ...any) Node

Form represents a document section containing interactive controls for submitting information.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/form

func H1

func H1(args ...any) Node

H1 creates a level 1 heading element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/h1

func H2

func H2(args ...any) Node

H2 creates a level 2 heading element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/h2

func H3

func H3(args ...any) Node

H3 creates a level 3 heading element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/h3

func H4

func H4(args ...any) Node

H4 creates a level 4 heading element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/h4

func H5

func H5(args ...any) Node

H5 creates a level 5 heading element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/h5

func H6

func H6(args ...any) Node

H6 creates a level 6 heading element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/h6

func Head(args ...any) Node

Head contains machine-readable information about the document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/head

func Header(args ...any) Node

Header creates a header element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/header

func Hgroup

func Hgroup(args ...any) Node

Hgroup groups a set of h1–h6 elements when they represent a multi-level heading.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/hgroup

func Hr

func Hr(attrs ...KV) Node

Hr represents a thematic break between paragraph-level elements.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/hr

func Html

func Html(args ...any) Node

Html creates the root element of an HTML document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/html

func I

func I(args ...any) Node

I represents text in an alternate voice or mood.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/i

func If

func If(condition bool, result Node) Node

Conditionally returns a Node based on a boolean condition.

This function returns an empty Node (not nil) when the condition is false, which prevents nil pointer issues when building DOM trees.

Example:

Body(
	If(showHeader, Header(...)),
	Main(...),
)

func Iframe

func Iframe(args ...any) Node

Iframe represents a nested browsing context, embedding another HTML page into the current one.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/iframe

func Img

func Img(attrs ...KV) Node

Img embeds an image into the document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img

func Input

func Input(attrs ...KV) Node

Input is used to create interactive controls for web-based forms to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The &lt;input&gt; element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input

func Ins

func Ins(args ...any) Node

Ins represents a range of text that has been added to a document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/ins

func Kbd

func Kbd(args ...any) Node

Kbd represents text that the user should enter.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/kbd

func Label

func Label(args ...any) Node

Label represents a caption for an item in a user interface.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/label

func Legend

func Legend(args ...any) Node

Legend represents a caption for the content of its parent &lt;fieldset&gt;.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/legend

func Li

func Li(args ...any) Node

Li represents a list item.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/li

func Link(attrs ...KV) Node

Link specifies relationships between the current document and an external resource.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link

func Main

func Main(args ...any) Node

Main creates a main content element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/main

func Map

func Map(args ...any) Node

Map is used with &lt;area&gt; elements to define an image map (a clickable link area).

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/map

func MapSlice

func MapSlice[T any](input []T, f func(T) Node) Node

MapSlice transforms a slice of items into Nodes by applying a function to each element.

Each element in the input slice is transformed using the provided function, and all resulting Nodes are aggregated into a single container Node.

Example:

items := []string{"Apple", "Banana", "Cherry"}
Ul(
	MapSlice(items, func(item string) Node {
		return Li(item)
	}),
)

func Mark

func Mark(args ...any) Node

Mark highlights text for reference.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/mark

func Math

func Math(args ...any) Node

Math is the top-level element in MathML. Every valid MathML instance must be wrapped in it. In addition, you must not nest a second &lt;math&gt; element in another, but you can have an arbitrary number of other child elements in it.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/math

func Menu(args ...any) Node

Menu represents a set of commands or options.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/menu

func Meta

func Meta(attrs ...KV) Node

Meta represents metadata that cannot be represented by other HTML meta-related elements.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/meta

func Meter

func Meter(args ...any) Node

Meter represents either a scalar value within a known range or a fractional value.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/meter

func Nav(args ...any) Node

Nav creates a navigation element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/nav

func Noscript

func Noscript(args ...any) Node

Noscript defines a section of HTML to be inserted if a script type on the page is unsupported or if scripting is currently turned off in the browser.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/noscript

func Object

func Object(args ...any) Node

Object represents an external resource, which can be treated as an image, a nested browsing context, or a resource to be handled by a plugin.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/object

func Ol

func Ol(args ...any) Node

Ol represents an ordered list.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/ol

func Optgroup

func Optgroup(args ...any) Node

Optgroup creates a grouping of options within a &lt;select&gt; element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/optgroup

func Option

func Option(args ...any) Node

Option is used to define an item contained in a &lt;select&gt;, an &lt;optgroup&gt;, or a &lt;datalist&gt; element. As such, &lt;option&gt; can represent menu items in popups and other lists of items in an HTML document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/option

func Output

func Output(args ...any) Node

Output is a container element into which a site or app can inject the results of a calculation or the outcome of a user action.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/output

func P

func P(args ...any) Node

P creates a paragraph element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/p

func Picture

func Picture(args ...any) Node

Picture defines multiple sources for an img element to offer alternative versions of an image for different display/device scenarios.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/picture

func Pre

func Pre(args ...any) Node

Pre represents preformatted text.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/pre

func Progress

func Progress(args ...any) Node

Progress displays an indicator showing the completion progress of a task, typically displayed as a progress bar.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/progress

func Q

func Q(args ...any) Node

Q indicates a short inline quotation.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/q

func Repeat

func Repeat(n int, f func() Node) Node

Repeat generates multiple Nodes by calling a function n times.

The provided function is called exactly n times, and each resulting Node is aggregated into a single container Node. Using a function ensures each Node instance is unique (important for elements with mutable state).

Example:

Ul(
	Repeat(5, func() Node {
		return Li("List item")
	}),
)

func Rp

func Rp(args ...any) Node

Rp provides parentheses for browsers that don't support ruby text.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/rp

func Rt

func Rt(args ...any) Node

Rt specifies the ruby text for ruby annotations.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/rt

func Ruby

func Ruby(args ...any) Node

Ruby represents ruby annotations for East Asian typography.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/ruby

func S

func S(args ...any) Node

S renders text with a strikethrough.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/s

func Samp

func Samp(args ...any) Node

Samp represents sample output from a computer program.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/samp

func Script

func Script(args ...any) Node

Script is used to embed executable code or data; this is typically used to embed or refer to JavaScript code. The &lt;script&gt; element can also be used with other languages, such as WebGL's GLSL shader programming language and JSON.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script

func Search(args ...any) Node

Search represents a search or filtering interface.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/search

func Section

func Section(args ...any) Node

Section creates a section element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/section

func Select

func Select(args ...any) Node

Select represents a control that provides a menu of options.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/select

func Selectedcontent

func Selectedcontent(args ...any) Node

Selectedcontent displays the content of the currently selected &lt;option&gt; inside a closed &lt;select&gt; element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/selectedcontent

func Slot

func Slot(args ...any) Node

Slot acts as a placeholder inside a web component that you can fill with your own markup, which lets you create separate DOM trees and present them together.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/slot

func Small

func Small(args ...any) Node

Small represents side-comments and small print.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/small

func Source

func Source(attrs ...KV) Node

Source specifies multiple media resources for the picture, the audio element, or the video element. It is a void element, meaning that it has no content and does not have a closing tag. It is commonly used to offer the same media content in multiple file formats in order to provide compatibility with a broad range of browsers given their differing support for image file formats and media file formats.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/source

func Span

func Span(args ...any) Node

Span is the generic inline container for phrasing content.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/span

func Strong

func Strong(args ...any) Node

Strong indicates strong importance.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/strong

func Style

func Style(args ...any) Node

Style contains style information for a document or part of a document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/style

func Sub

func Sub(args ...any) Node

Sub specifies inline text displayed as subscript.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/sub

func Summary

func Summary(args ...any) Node

Summary specifies a summary, caption, or legend for a details element's disclosure box. Clicking the &lt;summary&gt; element toggles the state of the parent &lt;details&gt; element open and closed.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/summary

func Sup

func Sup(args ...any) Node

Sup specifies inline text displayed as superscript.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/sup

func Svg

func Svg(args ...any) Node

Svg is a container defining a new coordinate system and viewport. It is used as the outermost element of SVG documents, but it can also be used to embed an SVG fragment inside an SVG or HTML document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/svg

func Table

func Table(args ...any) Node

Table represents tabular data—that is, information presented in a two-dimensional table comprised of rows and columns of cells containing data.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/table

func Tbody

func Tbody(args ...any) Node

Tbody groups the body content in a table with information about the table's columns. This is usually in the form of column headers (&lt;th&gt; elements).

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/tbody

func Td

func Td(args ...any) Node

Td is a child of the &lt;tr&gt; element, it defines a cell of a table that contains data.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/td

func Template

func Template(args ...any) Node

Template holds HTML that is not to be rendered immediately when a page is loaded but may be instantiated subsequently during runtime using JavaScript.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/template

func Textarea

func Textarea(args ...any) Node

Textarea represents a multi-line plain-text editing control, useful when you want to allow users to enter a sizeable amount of free-form text, for example, a comment on a review or feedback form.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/textarea

func Tfoot

func Tfoot(args ...any) Node

Tfoot groups the footer content in a table with information about the table's columns. This is usually a summary of the columns, e.g., a sum of the given numbers in a column.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/tfoot

func Th

func Th(args ...any) Node

Th is a child of the &lt;tr&gt; element, it defines a cell as the header of a group of table cells. The nature of this group can be explicitly defined by the scope and headers attributes.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/th

func Thead

func Thead(args ...any) Node

Thead groups the header content in a table with information about the table's columns. This is usually in the form of column headers (&lt;th&gt; elements).

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/thead

func Time

func Time(args ...any) Node

Time represents a specific period in time.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/time

func Title

func Title(args ...any) Node

Title defines the document's title that is shown in a browser's title bar or a page's tab.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/title

func Tr

func Tr(args ...any) Node

Tr defines a row of cells in a table. The row's cells can then be established using a mix of &lt;td&gt; (data cell) and &lt;th&gt; (header cell) elements.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/tr

func Track

func Track(attrs ...KV) Node

Track is used as a child of the media elements, audio and video. It lets you specify timed text tracks (or time-based data), for example to automatically handle subtitles. The tracks are formatted in WebVTT format (.vtt files)—Web Video Text Tracks.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/track

func U

func U(args ...any) Node

U represents text with an unarticulated annotation.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/u

func Ul

func Ul(args ...any) Node

Ul represents an unordered list.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/ul

func Var

func Var(args ...any) Node

Var represents a variable in a mathematical expression or programming context.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/var

func Video

func Video(args ...any) Node

Video embeds a media player which supports video playback into the document. You can also use &lt;video&gt; for audio content, but the audio element may provide a more appropriate user experience.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/video

func Wbr

func Wbr(attrs ...KV) Node

Wbr represents a word break opportunity.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/wbr

type RawHTML

type RawHTML string

RawHTML represents a text node that renders its content exactly as provided, without any HTML escaping.

func (RawHTML) Render

func (me RawHTML) Render(w io.Writer) error

Render implements the Node interface for RawHTML. It writes the raw HTML content without any escaping to the provided writer.

type ReferrerpolicyValue

type ReferrerpolicyValue = string

ReferrerpolicyValue represents valid values for the referrerpolicy attribute.

const (
	// ReferrerpolicyNoReferrer never sends the Referer header.
	ReferrerpolicyNoReferrer ReferrerpolicyValue = "no-referrer"
	// ReferrerpolicyNoReferrerWhenDowngrade omits Referer when going to less secure protocol.
	ReferrerpolicyNoReferrerWhenDowngrade ReferrerpolicyValue = "no-referrer-when-downgrade"
	// ReferrerpolicyOrigin sends only the origin in Referer.
	ReferrerpolicyOrigin ReferrerpolicyValue = "origin"
	// ReferrerpolicyOriginWhenCrossOrigin sends full URL for same-origin, origin for cross-origin.
	ReferrerpolicyOriginWhenCrossOrigin ReferrerpolicyValue = "origin-when-cross-origin"
	// ReferrerpolicyUnsafeURL sends full URL in Referer (may leak data).
	ReferrerpolicyUnsafeURL ReferrerpolicyValue = "unsafe-url"
	// ReferrerpolicyStrictOrigin sends only origin, omits for less secure destinations.
	ReferrerpolicyStrictOrigin ReferrerpolicyValue = "strict-origin"
	// ReferrerpolicyStrictOriginWhenCrossOrigin is strict-origin for cross-origin.
	ReferrerpolicyStrictOriginWhenCrossOrigin ReferrerpolicyValue = "strict-origin-when-cross-origin"
)

type RelValue

type RelValue = string

RelValue represents valid values for the rel attribute.

const (
	// RelStylesheet indicates the linked resource is a stylesheet.
	RelStylesheet RelValue = "stylesheet"
	// RelIcon indicates the linked resource is an icon or favicon.
	RelIcon RelValue = "icon"
	// RelShortcutIcon is a legacy value for favicons.
	RelShortcutIcon RelValue = "shortcut icon"
	// RelPreconnect advises the browser to preemptively initiate a connection.
	RelPreconnect RelValue = "preconnect"
	// RelPrefetch advises the browser to prefetch the target resource.
	RelPrefetch RelValue = "prefetch"
	// RelPrerender advises the browser to prerender the linked page.
	RelPrerender RelValue = "prerender"
	// RelDnsPrefetch advises the browser to perform DNS resolution.
	RelDnsPrefetch RelValue = "dns-prefetch"
	// RelPreload indicates the resource should be preemptively fetched.
	RelPreload RelValue = "preload"
	// RelModulepreload indicates the module script should be fetched and cached.
	RelModulepreload RelValue = "modulepreload"
	// RelAlternate indicates an alternate representation of the document.
	RelAlternate RelValue = "alternate"
	// RelAuthor provides a link to the author.
	RelAuthor RelValue = "author"
	// RelBookmark provides a permalink for the nearest section.
	RelBookmark RelValue = "bookmark"
	// RelCanonical identifies the preferred URL for the document.
	RelCanonical RelValue = "canonical"
	// RelHelp provides a link to context-sensitive help.
	RelHelp RelValue = "help"
	// RelLicense indicates the linked content contains licensing info.
	RelLicense RelValue = "license"
	// RelNext indicates the next document in a series.
	RelNext RelValue = "next"
	// RelNoFollow indicates the link should not be followed by search engines.
	RelNoFollow RelValue = "nofollow"
	// RelNoOpener prevents the linked page from accessing window.opener.
	RelNoOpener RelValue = "noopener"
	// RelNoReferrer prevents sending the Referer header.
	RelNoReferrer RelValue = "noreferrer"
	// RelPrev indicates the previous document in a series.
	RelPrev RelValue = "prev"
	// RelSearch provides a link to a search resource.
	RelSearch RelValue = "search"
	// RelTag gives a tag (keyword) for the document.
	RelTag RelValue = "tag"
)

type ScopeValue

type ScopeValue = string

ScopeValue represents valid values for the scope attribute of table headers.

const (
	// ScopeRow associates the header with a single row.
	ScopeRow ScopeValue = "row"
	// ScopeCol associates the header with a single column.
	ScopeCol ScopeValue = "col"
	// ScopeRowgroup associates the header with a group of rows.
	ScopeRowgroup ScopeValue = "rowgroup"
	// ScopeColgroup associates the header with a group of columns.
	ScopeColgroup ScopeValue = "colgroup"
)

type ScriptTypeValue

type ScriptTypeValue = string

ScriptTypeValue represents valid values for the type attribute of script elements.

const (
	// ScriptTypeJS is a classic JavaScript script (default).
	ScriptTypeJS ScriptTypeValue = "text/javascript"
	// ScriptTypeModule is an ES module.
	ScriptTypeModule ScriptTypeValue = "module"
	// ScriptTypeImportmap contains an import map.
	ScriptTypeImportmap ScriptTypeValue = "importmap"
	// ScriptTypeJSON contains JSON data.
	ScriptTypeJSON ScriptTypeValue = "application/json"
	// ScriptTypeSpeculation contains speculation rules.
	ScriptTypeSpeculation ScriptTypeValue = "speculationrules"
)

type TargetValue

type TargetValue = string

TargetValue represents valid values for the target attribute.

const (
	// TargetBlank opens the linked document in a new window or tab.
	TargetBlank TargetValue = "_blank"
	// TargetSelf opens the linked document in the same frame (default).
	TargetSelf TargetValue = "_self"
	// TargetParent opens the linked document in the parent frame.
	TargetParent TargetValue = "_parent"
	// TargetTop opens the linked document in the full body of the window.
	TargetTop TargetValue = "_top"
)

Directories

Path Synopsis
templ: version: v0.3.977
templ: version: v0.3.977

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL