Pure_html.HTMLAll standard HTML attributes and tags. Some attributes and tags have the same name, e.g. style. To disambiguate them, attributes have a _ (underscore) suffix.
Standard, most non-deprecated attributes from https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes. Where an attribute name conflicts with an OCaml keyword, the name is suffixed with _. Most attributes are constructed by passing in a value of some type.
All string-valued attributes allow formatting (interpolation):
div [id "section-%d" section_id] []Or plain strings:
p [id "toast"] []Most boolean attributes are plain values and don't need to be constructed with function calls:
input [required]However, boolean attributes which may be inherited and toggled on/off in children, are constructed by passing in a value.
Enumerated attributes accept specific values:
input [inputmode `tel]val null_ : attrAn attribute that will not be rendered in the markup. Useful for conditional logic where you sometimes want to render an attribute and sometimes not.
p
[(if should_show then null_ else style_ "display:none")]
[txt "Show and tell"]val accept : _ string_attrval accept_charset : _ string_attrval accesskey : _ string_attrval action : _ string_attrval align : _ string_attrval allow : _ string_attrval alt : _ string_attrval as_ : _ string_attrval async : attrval autocapitalize :
[< `off | `none | `on | `sentences | `words | `characters ] to_attrval autocomplete :
[< `off
| `on
| `name
| `honorific_prefix
| `given_name
| `additional_name
| `honorific_suffix
| `nickname
| `email
| `username
| `new_password
| `current_password
| `one_time_code
| `organization_title
| `organization
| `street_address
| `address_line1
| `address_line2
| `address_line3
| `address_level4
| `address_level3
| `address_level2
| `address_level1
| `country
| `country_name
| `postal_code
| `cc_name
| `cc_given_name
| `cc_additional_name
| `cc_family_name
| `cc_number
| `cc_exp
| `cc_exp_month
| `cc_exp_year
| `cc_csc
| `cc_type
| `transaction_currency
| `transaction_amount
| `language
| `bday
| `bday_day
| `bday_month
| `bday_year
| `sex
| `tel
| `tel_country_code
| `tel_national
| `tel_area_code
| `tel_local
| `tel_extension
| `impp
| `url
| `photo
| `webauthn ]
to_attrval autofocus : attrval autoplay : attrval buffered : _ string_attrval capture : [< `user | `environment ] to_attrval charset : _ string_attrval checked : attrval cite_ : _ string_attrval class_ : _ string_attrval color : _ string_attrval cols : int to_attrval colspan : int to_attrval content : _ string_attrval contenteditable : [< `true_ | `false_ | `plaintext_only ] to_attrval controls : attrval coords : _ string_attrval crossorigin : [< `anonymous | `use_credentials ] to_attrval data_ : _ string_attrval datetime : _ string_attrval decoding : [< `sync | `async | `auto ] to_attrval default : attrval defer : attrval dir : [< `ltr | `rtl | `auto ] to_attrval dirname : _ string_attrval disabled : attrval download : _ string_attrval draggable : attrval fetchpriority : [< `high | `low | `auto ] to_attrval for_ : _ string_attrval form_ : _ string_attrval formaction : _ string_attrval formnovalidate : attrval formtarget : _ string_attrval headers : _ string_attrval height : _ string_attrval high : float to_attrval href : _ string_attrval hreflang : _ string_attrval http_equiv :
[< `content_security_policy
| `content_type
| `default_style
| `x_ua_compatible
| `refresh ]
to_attrval id : _ string_attrval inert : attrval integrity : _ string_attrval inputmode :
[< `none | `text | `decimal | `numeric | `tel | `search | `email | `url ]
to_attrval ismap : attrval itemprop : _ string_attrval kind :
[< `subtitles | `captions | `descriptions | `chapters | `metadata ] to_attrval label_ : _ string_attrval lang : _ string_attrval list : _ string_attrval loading_lazy : attrSee https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#loading. loading=eager is the default so no need for specifically that value.
val loop : attrval low : float to_attrval max : _ string_attrval maxlength : int to_attrval media : _ string_attrval min : _ string_attrval minlength : int to_attrval multiple : attrval muted : attrval name : _ string_attrval novalidate : attrval onblur : _ string_attrNote that the value of this attribute is not escaped.
val onclick : _ string_attrNote that the value of this attribute is not escaped.
val open_ : attrval optimum : float to_attrval pattern : _ string_attrval ping : _ string_attrval placeholder : _ string_attrval playsinline : attrval popover : [< `auto | `manual ] to_attrval popovertarget : _ string_attrval popovertargetaction : [< `hide | `show ] to_attrtoggle is the default.
val poster : _ string_attrval preload : [< `none | `metadata | `auto ] to_attrval readonly : attrval referrerpolicy :
[< `no_referrer
| `no_referrer_when_downgrade
| `origin
| `origin_when_cross_origin
| `same_origin
| `strict_origin
| `strict_origin_when_cross_origin
| `unsafe_url ]
to_attrval rel : _ string_attrval required : attrval reversed : attrval role :
[ `alert
| `alertdialog
| `application
| `article
| `banner
| `button
| `cell
| `checkbox
| `columnheader
| `combobox
| `comment
| `complementary
| `contentinfo
| `definition
| `dialog
| `document
| `feed
| `figure
| `form
| `generic
| `grid
| `gridcell
| `group
| `heading
| `img
| `link
| `list
| `listbox
| `listitem
| `log
| `main
| `mark
| `marquee
| `math
| `menu
| `menubar
| `menuitem
| `menuitemcheckbox
| `menuitemradio
| `meter
| `navigation
| `none
| `note
| `option
| `presentation
| `progressbar
| `radio
| `radiogroup
| `region
| `row
| `rowgroup
| `rowheader
| `scrollbar
| `search
| `searchbox
| `separator
| `slider
| `spinbutton
| `status
| `suggestion
| `switch
| `tab
| `table
| `tablist
| `tabpanel
| `term
| `textbox
| `timer
| `toolbar
| `tooltip
| `tree
| `treegrid
| `treeitem ]
to_attrval rows : int to_attrval rowspan : int to_attrval sandbox : _ string_attrval scope : _ string_attrval selected : attrval shadowrootclonable : attrval shadowrootdelegatesfocus : attrval shadowrootmode : [ `open_ | `closed ] to_attrval shape : _ string_attrval size : _ string_attrval sizes : _ string_attrval slot_ : _ string_attrval span_ : int to_attrval spellcheck : bool to_attrval src : _ string_attrval srcdoc : _ string_attrval srclang : _ string_attrval srcset : _ string_attrval start : int to_attrval step : _ string_attrval style_ : _ string_attrNote that the value of this attribute is not escaped.
val tabindex : int to_attrval target : _ string_attrval title_ : _ string_attrval translate : [< `yes | `no ] to_attrval type_ : _ string_attrNote: this can't be restricted to just the allowed values for <input type>, because it's used in other elements e.g. <link type>.
val usemap : _ string_attrval value : _ string_attrval width : _ string_attrval wrap : [< `hard | `soft ] to_attrHTML tags. Most (standard tags) are constructed by passing a list of attributes and a list of children:
div [id "my-div"] [p [] [txt "Hello"]]Some (void elements) are constructed only with a list of attributes:
input [required; type_ "email"; name "email-addr"]Finally, a few (text elements) are constructed with a list of attributes and a single format string child:
title [] "Document title" title [] "My App ・ %s" page_name script []
{|alert('Careful, this is not escaped :-)');|}A tag that will not be rendered in the markup. Useful for containing a bunch of child nodes inside a single node without having to litter the DOM with an actual node. Also may be called 'splicing'.
null
[ p [] [txt "This paragraph."];
p [] [txt "And this paragraph."];
p []
[ txt
"Are spliced directly into the document without a containing node."
] ]Also useful for constructing a completely empty node that is erased when printing: null [].
val a : std_tagval address : std_tagval area : void_tagval abbr : std_tagval article : std_tagval aside : std_tagval audio : std_tagval b : std_tagval base : void_tagval bdi : std_tagval bdo : std_tagval blockquote : std_tagval body : std_tagval br : void_tagval button : std_tagval canvas : std_tagval caption : std_tagval cite : std_tagval code : std_tagval col : void_tagval colgroup : std_tagval data : std_tagval datalist : std_tagval dd : std_tagval del : std_tagval details : std_tagval dfn : std_tagval dialog : std_tagval div : std_tagval dl : std_tagval dt : std_tagval em : std_tagval embed : void_tagval fieldset : std_tagval figcaption : std_tagval figure : std_tagval form : std_tagval h1 : std_tagval h2 : std_tagval h3 : std_tagval h4 : std_tagval h5 : std_tagval h6 : std_tagval head : std_tagval header : std_tagval hgroup : std_tagval hr : void_tagval html : std_tagA <!DOCTYPE html> declaration is automatically prefixed when this tag is printed.
val i : std_tagval iframe : std_tagval img : void_tagval input : void_tagval ins : std_tagval kbd : std_tagval label : std_tagval legend : std_tagval li : std_tagval link : void_tagval main : std_tagval map : std_tagval mark : std_tagval meta : void_tagval meter : std_tagval noscript : std_tagval object_ : std_tagval ol : std_tagval optgroup : std_tagval option : _ text_tagval output : std_tagval p : std_tagval picture : std_tagval pre : std_tagval progress : std_tagval q : std_tagval rp : std_tagval rt : std_tagval ruby : std_tagval s : std_tagval samp : std_tagval script : _ text_tagNote that the content of this tag is not escaped.
val search : std_tagval section : std_tagval select : std_tagval selectedoption : std_tagval slot : std_tagval small : std_tagval source : void_tagval span : std_tagval strong : std_tagval style : _ text_tagNote that the content of this tag is not escaped.
val sub : std_tagval summary : std_tagval sup : std_tagval table : std_tagval tbody : std_tagval td : std_tagval template : std_tagval textarea : _ text_tagval tfoot : std_tagval th : std_tagval thead : std_tagval time : std_tagval title : _ text_tagval tr : std_tagval track : void_tagval u : std_tagval ul : std_tagval var : std_tagval video : std_tagval wbr : void_tag