type +'a elt = 'a Html.elt
Element constructors are in section elements. Most elements constructors are either nullary, unary or star, depending on the number of children they accept. Children are usually given as a list of elements. txt is used for text.
div [a [txt "Foo"]] is equivalent to
The type variable
'a is used to track the element's type. This allows the OCaml typechecker to check HTML validity.
Note that the concrete implementation of this type can vary. See
Xml for details.
type +'a attrib = 'a Html.attrib
Attribute constructors are in section attributes and their name starts with
a_. Attributes are given to elements with the
~a optional argument.
a ~a:[a_href "ocsigen.org"] [txt "link!"] is equivalent to
Similarly to elt, attributes use the OCaml type system to enforce HTML validity.
a_href returns a value of type
[> `Href] attrib. The div function only accepts attributes of type
`Href is not part of it,
div ~a:[a_href "ocsigen.org"]  will not typecheck.
In some cases, attributes have to be disambiguated. The
max attribute has two version,
a_input_max, depending on the element. Such disambiguated attribute will contain the name of the associated element.
module Xml : Xml_sigs.T with type 'a W.t = 'a Xml.W.t with type 'a W.tlist = 'a Xml.W.tlist with type ('a, 'b) W.ft = ( 'a, 'b ) Xml.W.ft with type uri = Xml.uri with type event_handler = Xml.event_handler with type mouse_event_handler = Xml.mouse_event_handler with type keyboard_event_handler = Xml.keyboard_event_handler with type touch_event_handler = Xml.touch_event_handler with type attrib = Xml.attrib with type elt = Xml.elt
Underlying XML data-structure
type 'a wrap = 'a Xml.W.t
wrap is a container for elements and values.
In most cases,
'a wrap = 'a. For
R modules (in eliom or js_of_ocaml), It will be
type 'a list_wrap = 'a Xml.W.tlist
list_wrap is a container for list of elements.
In most cases,
'a list_wrap = 'a list. For
R modules (in eliom or js_of_ocaml), It will be
A nullary element is an element that doesn't have any children.
A unary element is an element that have exactly one children.
A star element is an element that has any number of children, including zero.
type uri = Xml.uri
This attribute assigns a class name or set of class names to an element. Any number of elements may be assigned the same class name or names.
May be used to specify custom attributes. The example given by the W3C is as follows :
<ol> <li data-length="2m11s">Beyond The Sea</li> </ol>
It should be used for preprocessing ends only.
This attribute assigns a name to an element. This name must be unique in a document. The text should be without any space.
This attribute offers advisory information about the element for which it is set.
Values of the title attribute may be rendered by user agents in a variety of ways. For instance, visual browsers frequently display the title as a tool tip (a short message that appears when the pointing device pauses over an object). Audio user agents may speak the title information in a similar context.
The title attribute has an additional role when used with the
link element to designate an external style sheet. Please consult the section on links and style sheets for details.
val a_allowfullscreen : unit -> [> `Allowfullscreen ] attrib
val a_allowpaymentrequest : unit -> [> `Allowpaymentrequest ] attrib
val a_async : unit -> [> `Async ] attrib
val a_autofocus : unit -> [> `Autofocus ] attrib
val a_autoplay : unit -> [> `Autoplay ] attrib
val a_muted : unit -> [> `Muted ] attrib
val a_controls : unit -> [> `Controls ] attrib
val a_formnovalidate : unit -> [> `Formnovalidate ] attrib
val a_ismap : unit -> [> `Ismap ] attrib
val a_loop : unit -> [> `Loop ] attrib
val a_inputmode : [< `None | `Text | `Decimal | `Numeric | `Tel | `Search | `Email | `Url ] wrap -> [> `Inputmode ] attrib
val a_novalidate : unit -> [> `Novalidate ] attrib
val a_open : unit -> [> `Open ] attrib
val a_pubdate : unit -> [> `Pubdate ] attrib
val a_required : unit -> [> `Required ] attrib
val a_reversed : unit -> [> `Reversed ] attrib
val a_scoped : unit -> [> `Scoped ] attrib
val a_seamless : unit -> [> `Seamless ] attrib
This attribute assigns an access key to an element. An access key is a single character from the document character set. NB: authors should consider the input method of the expected reader when specifying an accesskey.
This attribute specifies the character encoding of the resource designated by the link. Please consult the section on character encodings for more details.
This attribute specifies the location of a Web resource, thus defining a link between the current element (the source anchor) and the destination anchor defined by this attribute.
This attribute specifies the base language of the resource designated by href and may only be used when href is specified.
This attribute describes the relationship from the current document to the anchor specified by the href attribute. The value of this attribute is a space-separated list of link types.
This attribute is used to describe a reverse link from the anchor specified by the href attribute to the current document. The value of this attribute is a space-separated list of link types.
This attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros.
This attribute gives an advisory hint as to the content type of the content available at the link target address. It allows user agents to opt to use a fallback mechanism rather than fetch the content if they are advised that they will get content in a content type they do not support.Authors who use this attribute take responsibility to manage the risk that it may become inconsistent with the content available at the link target address.
This attribute specifies a form processing agent. User agent behavior for a value other than an HTTP URI is undefined.
val a_checked : unit -> [> `Checked ] attrib
type attribute has the value
"checkbox", this boolean attribute specifies that the button is on. User agents must ignore this attribute for other control types.
This attribute specifies the visible width in average character widths. Users should be able to enter longer lines than this, so user agents should provide some means to scroll through the contents of the control when the contents extend beyond the visible area. User agents may wrap visible text lines to keep long lines visible without the need for scrolling.
val a_multiple : unit -> [> `Multiple ] attrib
This attribute specifies the number of visible text lines. Users should be able to enter more lines than this, so user agents should provide some means to scroll through the contents of the control when the contents extend beyond the visible area.
val a_selected : unit -> [> `Selected ] attrib
When set, this boolean attribute specifies that this option is pre-selected.
This attribute specifies the initial value of the control. If this attribute is not set, the initial value is set to the contents of the
val a_disabled : unit -> [> `Disabled ] attrib
val a_readonly : unit -> [> `ReadOnly ] attrib
val a_defer : unit -> [> `Defer ] attrib
WAI-ARIA is a specification written by the W3C, defining a set of additional HTML attributes that can be applied to elements to provide additional semantics and improve accessibility wherever it is lacking.
See for example a WAI-ARIA tutorial.
Basic support for WAI-ARIA attributes:
a_aria "foo" corresponds to an "aria-foo" attribute.
val picture : img:[< Html_types.img ] elt wrap -> ( [< Html_types.picture_attrib ], [< Html_types.picture_content_fun ], [> Html_types.picture ] ) star
val label : ( [< Html_types.label_attrib ], [< Html_types.label_content_fun ], [> Html_types.label ] ) star
Label authorizes only one control inside them that should be labelled with a
for attribute (although it is not necessary). Such constraints are not currently enforced by the type-system
entity "foo" is the HTML entity
&foo;. Both numerical and named form are allowed.
val template : ( [< Html_types.template_attrib ], [< Html_types.template_content_fun ], [> Html_types.template ] ) star
WARNING: These functions do not ensure HTML or SVG validity! You should always explicitly given an appropriate type to the output.
import signal converts the given XML signal into Tyxml elements. It can be used with HTML and SVG parsing libraries, such as Markup.
module Unsafe : sig ... end