package dream-html

  1. Overview
  2. Docs

Module Dream_html.HTMLSource

All standard HTML attributes and tags. Some attributes and tags have the same name, e.g. style. To disambiguate them, attributes have a _ (underscore) suffix.

Attributes

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:

div [contenteditable true] [
    p [] [txt "Edit me!"];
    p [contenteditable false] [txt "Can't edit me!"];
  ]

Enumerated attributes accept specific values:

input [inputmode `tel]
  • since 1.0.0.
Sourcetype enctype = [
  1. | `urlencoded
  2. | `formdata
  3. | `text_plain
]
Sourcetype method_ = [
  1. | `GET
  2. | `POST
  3. | `dialog
    (*
    • since 2.1.0
    *)
]
Sourceval null_ : attr

An 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"]
Sourceval accept : _ string_attr
Sourceval accept_charset : _ string_attr
Sourceval accesskey : _ string_attr
Sourceval action : _ string_attr
Sourceval align : _ string_attr
  • deprecated See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
Sourceval allow : _ string_attr
Sourceval alt : _ string_attr
Sourceval async : attr
Sourceval autocapitalize : [< `off | `none | `on | `sentences | `words | `characters ] to_attr
Sourceval 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_attr
Sourceval autofocus : attr
Sourceval autoplay : attr
Sourceval buffered : _ string_attr
Sourceval capture : [< `user | `environment ] to_attr
Sourceval charset : _ string_attr
Sourceval checked : attr
Sourceval cite_ : _ string_attr
Sourceval class_ : _ string_attr
Sourceval color : _ string_attr
  • deprecated See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font#color
Sourceval cols : int to_attr
Sourceval colspan : int to_attr
Sourceval content : _ string_attr
Sourceval contenteditable : bool to_attr
Sourceval contextmenu : _ string_attr
Sourceval controls : attr
Sourceval coords : _ string_attr
Sourceval crossorigin : [< `anonymous | `use_credentials ] to_attr
Sourceval data_ : _ string_attr
Sourceval datetime : _ string_attr
Sourceval decoding : [< `sync | `async | `auto ] to_attr
Sourceval default : attr
Sourceval defer : attr
Sourceval dir : [< `ltr | `rtl | `auto ] to_attr
Sourceval dirname : _ string_attr
Sourceval disabled : attr
Sourceval download : _ string_attr
Sourceval draggable : attr
Sourceval enctype : [< enctype ] to_attr
Sourceval fetchpriority : [< `high | `low | `auto ] to_attr
  • since 1.2.0.
Sourceval for_ : _ string_attr
Sourceval form_ : _ string_attr
Sourceval formaction : _ string_attr
Sourceval formenctype : [< enctype ] to_attr
Sourceval formmethod : [< method_ ] to_attr
Sourceval formnovalidate : attr
Sourceval formtarget : _ string_attr
Sourceval headers : _ string_attr
Sourceval height : _ string_attr
Sourceval hidden : [< `hidden | `until_found ] to_attr
Sourceval high : float to_attr
Sourceval href : _ string_attr
Sourceval hreflang : _ string_attr
Sourceval http_equiv : [< `content_security_policy | `content_type | `default_style | `x_ua_compatible | `refresh ] to_attr
Sourceval integrity : _ string_attr
Sourceval inputmode : [< `none | `text | `decimal | `numeric | `tel | `search | `email | `url ] to_attr
Sourceval ismap : attr
Sourceval itemprop : _ string_attr
Sourceval kind : [< `subtitles | `captions | `descriptions | `chapters | `metadata ] to_attr
Sourceval label_ : _ string_attr
Sourceval lang : _ string_attr
Sourceval list : _ string_attr
Sourceval loading_lazy : attr

See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#loading. loading=eager is the default so no need for specifically that value.

  • since 3.1.0.
Sourceval loop : attr
Sourceval low : float to_attr
Sourceval max : _ string_attr
Sourceval maxlength : int to_attr
Sourceval media : _ string_attr
Sourceval method_ : [< method_ ] to_attr
Sourceval min : _ string_attr
Sourceval minlength : int to_attr
Sourceval multiple : attr
Sourceval muted : attr
Sourceval name : _ string_attr
Sourceval novalidate : attr
Sourceval onblur : _ string_attr

Note that the value of this attribute is not escaped.

Sourceval onclick : _ string_attr

Note that the value of this attribute is not escaped.

Sourceval open_ : attr
Sourceval optimum : float to_attr
Sourceval pattern : _ string_attr
Sourceval ping : _ string_attr
Sourceval placeholder : _ string_attr
Sourceval playsinline : attr
Sourceval poster : _ string_attr
Sourceval preload : [< `none | `metadata | `auto ] to_attr
Sourceval readonly : attr
Sourceval referrerpolicy : [< `no_referrer | `no_referrer_when_downgrade | `origin | `origin_when_cross_origin | `same_origin | `strict_origin | `strict_origin_when_cross_origin | `unsafe_url ] to_attr
Sourceval rel : _ string_attr
Sourceval required : attr
Sourceval reversed : attr
Sourceval 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_attr
  • since 3.0.0
Sourceval rows : int to_attr
Sourceval rowspan : int to_attr
Sourceval sandbox : _ string_attr
Sourceval scope : _ string_attr
Sourceval selected : attr
Sourceval shape : _ string_attr
Sourceval sizes : _ string_attr
Sourceval slot_ : _ string_attr
Sourceval span_ : int to_attr
Sourceval spellcheck : bool to_attr
Sourceval src : _ string_attr
Sourceval srcdoc : _ string_attr
Sourceval srclang : _ string_attr
Sourceval srcset : _ string_attr
Sourceval start : int to_attr
Sourceval step : _ string_attr
Sourceval style_ : _ string_attr

Note that the value of this attribute is not escaped.

Sourceval tabindex : int to_attr
Sourceval target : _ string_attr
Sourceval title_ : _ string_attr
Sourceval translate : [< `yes | `no ] to_attr
Sourceval type_ : _ string_attr

Note: this can't be restricted to just the allowed values for <input type>, because it's used in other elements e.g. <link type>.

Sourceval usemap : _ string_attr
Sourceval value : _ string_attr
Sourceval width : _ string_attr
Sourceval wrap : [< `hard | `soft ] to_attr

Tags

HTML 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 :-)');|}
Sourceval null : node list -> node

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 []
Sourceval address : std_tag
Sourceval area : void_tag
Sourceval abbr : std_tag
Sourceval article : std_tag
Sourceval aside : std_tag
Sourceval audio : std_tag
Sourceval base : void_tag
Sourceval bdi : std_tag
Sourceval bdo : std_tag
Sourceval blockquote : std_tag
Sourceval body : std_tag
Sourceval button : std_tag
Sourceval canvas : std_tag
Sourceval caption : std_tag
Sourceval cite : std_tag
Sourceval code : std_tag
Sourceval col : void_tag
Sourceval colgroup : std_tag
Sourceval data : std_tag
Sourceval datalist : std_tag
Sourceval dd : std_tag
Sourceval del : std_tag
Sourceval details : std_tag
Sourceval dfn : std_tag
Sourceval dialog : std_tag
Sourceval div : std_tag
Sourceval dl : std_tag
Sourceval dt : std_tag
Sourceval em : std_tag
Sourceval embed : void_tag
Sourceval fieldset : std_tag
Sourceval figcaption : std_tag
Sourceval figure : std_tag
Sourceval form : std_tag
Sourceval h1 : std_tag
Sourceval h2 : std_tag
Sourceval h3 : std_tag
Sourceval h4 : std_tag
Sourceval h5 : std_tag
Sourceval h6 : std_tag
Sourceval head : std_tag
Sourceval header : std_tag
Sourceval hgroup : std_tag
Sourceval html : std_tag

A <!DOCTYPE html> declaration is automatically prefixed when this tag is printed.

Sourceval iframe : std_tag
Sourceval img : void_tag
Sourceval input : void_tag
Sourceval ins : std_tag
Sourceval kbd : std_tag
Sourceval label : std_tag
Sourceval legend : std_tag
Sourceval li : std_tag
Sourceval main : std_tag
Sourceval map : std_tag
Sourceval mark : std_tag
Sourceval menu : std_tag
Sourceval meta : void_tag
Sourceval meter : std_tag
Sourceval nav : std_tag
Sourceval noscript : std_tag
Sourceval object_ : std_tag
Sourceval ol : std_tag
Sourceval optgroup : std_tag
Sourceval option : _ text_tag
Sourceval output : std_tag
Sourceval picture : std_tag
Sourceval pre : std_tag
Sourceval progress : std_tag
Sourceval rp : std_tag
Sourceval rt : std_tag
Sourceval ruby : std_tag
Sourceval samp : std_tag
Sourceval script : _ text_tag

Note that the content of this tag is not escaped.

Sourceval section : std_tag
Sourceval select : std_tag
Sourceval slot : std_tag
Sourceval small : std_tag
Sourceval source : void_tag
Sourceval span : std_tag
Sourceval strong : std_tag
Sourceval style : _ text_tag

Note that the content of this tag is not escaped.

Sourceval sub : std_tag
Sourceval summary : std_tag
Sourceval sup : std_tag
Sourceval table : std_tag
Sourceval tbody : std_tag
Sourceval td : std_tag
Sourceval template : std_tag
Sourceval textarea : _ text_tag
Sourceval tfoot : std_tag
Sourceval th : std_tag
Sourceval thead : std_tag
Sourceval time : std_tag
Sourceval title : _ text_tag
Sourceval tr : std_tag
Sourceval track : void_tag
Sourceval ul : std_tag
Sourceval var : std_tag
Sourceval video : std_tag
Sourceval wbr : void_tag
OCaml

Innovation. Community. Security.