package dream-html

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Dream_html.AttrSource

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]
Sourcetype enctype = [
  1. | `urlencoded
  2. | `formdata
  3. | `text_plain
]
Sourcetype method_ = [
  1. | `GET
  2. | `POST
]
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
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 ] to_attr
Sourceval autofocus : attr
Sourceval autoplay : attr
Sourceval buffered : _ string_attr
Sourceval capture : _ string_attr
Sourceval charset : _ string_attr
Sourceval checked : attr
Sourceval cite : _ string_attr
Sourceval class_ : _ string_attr
Sourceval color : _ string_attr
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 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 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 : _ string_attr
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 size : _ 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 on other elements e.g. <link type>.

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

Innovation. Community. Security.