Module Tw_html.AtSource

Functions for creating HTML attributes.

Sourceval id : string -> attr

id "my-id" creates an id attribute.

Global attributes

Sourceval title : string -> attr

title s creates a title attribute.

Sourceval lang : string -> attr

lang "en" creates a lang attribute.

Sourceval dir : string -> attr

dir "ltr" creates a dir attribute.

Sourceval tabindex : int -> attr

tabindex 0 creates a tabindex attribute.

Sourceval contenteditable : bool -> attr

contenteditable true creates a contenteditable attribute.

Sourceval spellcheck : string -> attr

spellcheck value sets the spellcheck attribute. Use "true" or "false".

Sourceval onclick : string -> attr

onclick "..." creates an onclick attribute.

Event attributes

Sourceval onchange : string -> attr

onchange "..." creates an onchange attribute.

Sourceval oninput : string -> attr

oninput "..." creates an oninput attribute.

Sourceval onsubmit : string -> attr

onsubmit "..." creates an onsubmit attribute.

Sourceval type' : string -> attr

type' "text/css" creates a type attribute.

Form attributes

Sourceval value : string -> attr

value "..." creates a value attribute.

Sourceval name : string -> attr

name "description" creates a name attribute.

Sourceval placeholder : string -> attr

placeholder "..." creates a placeholder attribute.

Sourceval required : attr

The required attribute.

Sourceval disabled : attr

The disabled attribute.

Sourceval checked : attr

The checked attribute.

Sourceval readonly : attr

The readonly attribute.

Sourceval href : string -> attr

href "/path" creates an href attribute.

Sourceval target : string -> attr

target "_blank" creates a target attribute.

Sourceval rel : string -> attr

rel "stylesheet" creates a rel attribute.

Sourceval download : string -> attr

download "file.pdf" creates a download attribute.

Sourceval src : string -> attr

src "/image.png" creates a src attribute.

Media attributes

Sourceval alt : string -> attr

alt "description" creates an alt attribute for images.

Sourceval width : int -> attr

width 800 creates a width attribute.

Sourceval height : int -> attr

height 600 creates a height attribute.

Sourceval loading : string -> attr

loading "lazy" creates a loading attribute.

Sourceval charset : string -> attr

charset "utf-8" creates a charset attribute.

Meta attributes

Sourceval content : string -> attr

content "..." creates a content attribute.

Sourceval property : string -> attr

property "og:title" creates a property attribute.

Sourceval style : string -> attr

style "color:red;" creates a style attribute.

Style attribute

Sourceval datetime : string -> attr

datetime "2025-07-28" creates a datetime attribute.

Time attributes

Sourceval srcset : string -> attr

srcset "..." creates a srcset attribute for responsive images.

Image attributes

Sourceval sizes : string -> attr

sizes "..." creates a sizes attribute for responsive images.

Sourceval title' : string -> attr

title' s creates a title attribute for elements.

Additional attributes

Sourceval loading_lazy : attr

The loading="lazy" attribute.

Sourceval v : string -> string -> attr

v key value creates a generic key-value attribute.

Sourceval void : attr

void is an empty attribute that doesn't render.

Sourceval true' : string -> attr

true' key creates a boolean attribute with a "true" value.

Sourceval false' : string -> attr

false' key creates a boolean attribute with a "false" value.

Sourceval if' : bool -> attr -> attr

if' cond at is at if cond is true, otherwise returns a void attribute.

Sourceval if_some : attr option -> attr

if_some o is at if o is Some at and void if o is None.

Sourceval is_void : attr -> bool

is_void at is true if the attribute is void (won't render).

Sourceval to_pair : attr -> string * string

to_pair at returns the attribute as a (name, value) pair.

Sourceval of_pair : (string * string) -> attr

of_pair (n,v) creates an attribute from a (name, value) pair.

Additional HTML5 attributes

Sourceval accesskey : string -> attr

accesskey key sets keyboard shortcut.

Sourceval action : string -> attr

action url sets form action URL.

Sourceval autocomplete : string -> attr

autocomplete value sets autocomplete behavior.

Sourceval autofocus : attr

autofocus sets element to be focused on page load.

Sourceval cols : int -> attr

cols n sets textarea columns.

Sourceval colspan : int -> attr

colspan n sets table cell column span.

Sourceval defer : attr

defer defers script execution.

Sourceval draggable : bool -> attr

draggable b sets whether element is draggable.

Sourceval for' : string -> attr

for' id associates label with form element.

Sourceval hidden : attr

hidden hides the element.

Sourceval list : string -> attr

list id associates input with datalist.

Sourceval method' : string -> attr

method' m sets form HTTP method.

Sourceval media : string -> attr

media query sets media query for resources.

Sourceval popover : string -> attr

popover value sets popover behavior.

Sourceval popovertarget : string -> attr

popovertarget id sets popover target element.

Sourceval popovertargetaction : string -> attr

popovertargetaction action sets popover action.

Sourceval rows : int -> attr

rows n sets textarea rows.

Sourceval rowspan : int -> attr

rowspan n sets table cell row span.

Sourceval selected : attr

selected marks option as selected.

Sourceval wrap : string -> attr

wrap mode sets textarea wrap mode.

SVG Attributes

Sourceval fill_rule : [ `evenodd ] -> attr

fill_rule `evenodd sets the fill rule.

Sourceval clip_rule : [ `evenodd ] -> attr

clip_rule `evenodd sets the clipping rule.

Sourceval cx : int -> attr

cx n sets the center x coordinate.

Sourceval cy : int -> attr

cy n sets the center y coordinate.

Sourceval r : int -> attr

r n sets the radius.

Sourceval view_box : string -> attr

view_box s sets the viewBox.

Sourceval fill : string -> attr

fill "currentColor" sets the fill color.

Sourceval stroke : string -> attr

stroke "currentColor" sets the stroke color.

Sourceval stroke_width : string -> attr

stroke_width "2" sets the stroke width.

Sourceval stroke_linecap : string -> attr

stroke_linecap "round" sets the stroke line cap.

Sourceval stroke_linejoin : string -> attr

stroke_linejoin "round" sets the stroke line join.

Sourceval x : string -> attr

x "10" sets the x coordinate.

Sourceval y : string -> attr

y "10" sets the y coordinate.

Sourceval rx : string -> attr

rx "5" sets the x radius for rounded rectangles.

Sourceval d : string -> attr

d s sets the path data.

Sourceval x1 : string -> attr

x1 "0" sets the first x coordinate.

Sourceval y1 : string -> attr

y1 "0" sets the first y coordinate.

Sourceval x2 : string -> attr

x2 "20" sets the second x coordinate.

Sourceval y2 : string -> attr

y2 "20" sets the second y coordinate.