Html_f.MakeSourceCreate a new implementation of HTML, using the given underlying Xml and Svg implementation. Will output a module of type Html_sigs.T with the various type equalities.
If your Xml implementation uses a special function wrapping, use Make_with_wrapped_functions.
module Xml : Xml_sigs.T with type ('a, 'b) W.ft = 'a -> 'bmodule Svg : Svg_sigs.T with module Xml := XmlHTML elements.
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 <div><a>foo</a></div>
The type variable 'a is used to track the element's type. This allows the OCaml typechecker to check HTML validity.
For example, div [] is of type [> `Div] elt. The span function only accepts children of type Html_types.span_content. Since `Div is not part of it. span [div []] will not typecheck.
Note that the concrete implementation of this type can vary. See Xml for details.
A complete HTML document.
HTML attributes
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 <a href="ocsigen.org">link!</a>
Similarly to elt, attributes use the OCaml type system to enforce HTML validity.
For example a_href returns a value of type [> `Href] attrib. The div function only accepts attributes of type Html_types.div_attrib. Since `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_max and 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.eltUnderlying XML data-structure
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 React.S.t.
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 ReactiveData.RList.t.
A nullary element is an element that doesn't have any children.
A unary element is an element that has exactly one child.
A star element is an element that has any number of children, including zero.
Various information about HTML, such as the doctype, ...
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.
In the DOM, pointer events inherit from mouse events, so the handlers use Xml.mouse_event_handler.
Touch events
Alternative label of a header cell, for reference in other cells.
Permissions policy of an iframe.
val a_autocapitalize :
[< `Off | `None | `On | `Sentences | `Words | `Characters ] wrap ->
[> `Autocapitalize ] attribval a_as :
[< `Audio
| `Document
| `Embed
| `Fetch
| `Font
| `Image
| `Object
| `Script
| `Style
| `Track
| `Video
| `Worker ]
wrap ->
[> `As ] attribDestination of a preload link. This covers the destinations listed by MDN; other spec destinations can be produced with Unsafe.string_attrib.
User actions that can close a dialog.
Preferred camera for file inputs capturing media. Defined by the W3C HTML Media Capture specification. The bare form of the attribute is not supported by the PPX; use an explicit value.
A bare contenteditable attribute is equivalent to contenteditable="true".
Name of the form control field used to submit the element's text directionality.
val a_enterkeyhint :
[< `Enter | `Done | `Go | `Next | `Previous | `Search | `Send ] wrap ->
[> `Enterkeyhint ] attribA bare hidden attribute is equivalent to hidden="hidden"; use `Until_found for the hidden-until-found state.
Name of a customized built-in element.
Microdata: space-separated list of vocabulary URLs for the item.
Microdata: space-separated list of names of the property.
Microdata: additional elements to crawl to find the name-value pairs of the item.
val a_inputmode :
[< `None | `Text | `Decimal | `Numeric | `Tel | `Search | `Email | `Url ]
wrap ->
[> `Inputmode ] attribIndicates that a classic script must not run in browsers that support module scripts.
Cryptographic nonce used by Content Security Policy.
Space-separated list of URLs to ping when following the hyperlink.
Indicates that a video is to be played inline, within the element's playback area.
Defined by the W3C Picture-in-Picture specification.
Defined by the W3C Remote Playback specification.
Space-separated list of part names of the element, exposed to shadow-tree styling. Defined by the CSS Shadow Parts specification, not by the HTML standard.
Comma-separated list of part mappings (name or name:exposed-name) forwarded from a nested shadow tree. Defined by the CSS Shadow Parts specification, not by the HTML standard.
In HTML, a bare popover attribute is equivalent to popover="auto".
Id of the popover element to control with a button.
val a_popovertargetaction :
[< `Show | `Hide | `Toggle ] wrap ->
[> `Popovertargetaction ] attribAction to perform on the element targeted by a button (Invoker Commands API).
Id of the element a button command targets.
Space-separated list of operations blocked on the fetching of a script, style sheet or style-relevant link.
Declarative shadow root mode, for template elements.
Name of the shadow tree slot the element is assigned to.
Inline HTML document of an iframe, given as escaped text.
val a_kind :
[< `Subtitles | `Captions | `Descriptions | `Chapters | `Metadata ] wrap ->
[> `Kind ] attribHow a text track is meant to be used, for track elements.
Language of the text track data, for track elements.
Indicates that a text track is to be enabled if the user's preferences do not indicate that another track would be more appropriate.
type image_candidate = [ | `Url of uri| `Url_width of uri * Html_types.number| `Url_pixel of uri * Html_types.float_number ]Images to preload, for link elements with rel=preload and as=image.
Numbering type of an ordered list.
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.
When the type attribute has the value "radio" or "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.
This attribute assigns the control name.
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.
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 option element.
Specifies the cells that a header cell applies to.
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 html :
?a:Html_types.html_attrib attrib list ->
[< Html_types.head ] elt wrap ->
[< Html_types.body ] elt wrap ->
[> Html_types.html ] eltval head :
?a:Html_types.head_attrib attrib list ->
[< Html_types.title ] elt wrap ->
Html_types.head_content_fun elt list_wrap ->
[> Html_types.head ] eltval title :
(Html_types.title_attrib,
[< Html_types.title_content_fun ],
[> Html_types.title ])
unaryval body :
([< Html_types.body_attrib ],
[< Html_types.body_content_fun ],
[> Html_types.body ])
starval svg :
?a:[< Html_types.svg_attrib ] Svg.attrib list ->
[< Html_types.svg_content ] Svg.elt list_wrap ->
[> Html_types.svg ] eltval header :
([< Html_types.header_attrib ],
[< Html_types.header_content_fun ],
[> Html_types.header ])
starval section :
([< Html_types.section_attrib ],
[< Html_types.section_content_fun ],
[> Html_types.section ])
starval hgroup :
([< Html_types.hgroup_attrib ],
[< Html_types.hgroup_content_fun ],
[> Html_types.hgroup ])
starval address :
([< Html_types.address_attrib ],
[< Html_types.address_content_fun ],
[> Html_types.address ])
starval article :
([< Html_types.article_attrib ],
[< Html_types.article_content_fun ],
[> Html_types.article ])
starval aside :
([< Html_types.aside_attrib ],
[< Html_types.aside_content_fun ],
[> Html_types.aside ])
starval main :
([< Html_types.main_attrib ],
[< Html_types.main_content_fun ],
[> Html_types.main ])
starval search :
([< Html_types.search_attrib ],
[< Html_types.search_content_fun ],
[> Html_types.search ])
starval pre :
([< Html_types.pre_attrib ],
[< Html_types.pre_content_fun ],
[> Html_types.pre ])
starval blockquote :
([< Html_types.blockquote_attrib ],
[< Html_types.blockquote_content_fun ],
[> Html_types.blockquote ])
starval dialog :
([< Html_types.dialog_attrib ],
[< Html_types.dialog_content_fun ],
[> Html_types.dialog ])
starval div :
([< Html_types.div_attrib ],
[< Html_types.div_content_fun ],
[> Html_types.div ])
starval figcaption :
([< Html_types.figcaption_attrib ],
[< Html_types.figcaption_content_fun ],
[> Html_types.figcaption ])
starval figure :
?figcaption:
[ `Top of [< Html_types.figcaption ] elt wrap
| `Bottom of [< Html_types.figcaption ] elt wrap ] ->
([< Html_types.figure_attrib ],
[< Html_types.figure_content_fun ],
[> Html_types.figure ])
starval small :
([< Html_types.small_attrib ],
[< Html_types.small_content_fun ],
[> Html_types.small ])
starval sub :
([< Html_types.sub_attrib ],
[< Html_types.sub_content_fun ],
[> Html_types.sub ])
starval sup :
([< Html_types.sup_attrib ],
[< Html_types.sup_content_fun ],
[> Html_types.sup ])
starval mark :
([< Html_types.mark_attrib ],
[< Html_types.mark_content_fun ],
[> Html_types.mark ])
starval bdo :
dir:[< `Ltr | `Rtl ] wrap ->
([< Html_types.bdo_attrib ],
[< Html_types.bdo_content_fun ],
[> Html_types.bdo ])
starval bdi :
([< Html_types.bdi_attrib ],
[< Html_types.bdi_content_fun ],
[> Html_types.bdi ])
starval abbr :
([< Html_types.abbr_attrib ],
[< Html_types.abbr_content_fun ],
[> Html_types.abbr ])
starval cite :
([< Html_types.cite_attrib ],
[< Html_types.cite_content_fun ],
[> Html_types.cite ])
starval code :
([< Html_types.code_attrib ],
[< Html_types.code_content_fun ],
[> Html_types.code ])
starval dfn :
([< Html_types.dfn_attrib ],
[< Html_types.dfn_content_fun ],
[> Html_types.dfn ])
starval kbd :
([< Html_types.kbd_attrib ],
[< Html_types.kbd_content_fun ],
[> Html_types.kbd ])
starval samp :
([< Html_types.samp_attrib ],
[< Html_types.samp_content_fun ],
[> Html_types.samp ])
starval span :
([< Html_types.span_attrib ],
[< Html_types.span_content_fun ],
[> Html_types.span ])
starval strong :
([< Html_types.strong_attrib ],
[< Html_types.strong_content_fun ],
[> Html_types.strong ])
starval time :
([< Html_types.time_attrib ],
[< Html_types.time_content_fun ],
[> Html_types.time ])
starval data :
value:Html_types.text wrap ->
([< Html_types.data_attrib ],
[< Html_types.data_content_fun ],
[> Html_types.data ])
stardata ~value content represents content together with its machine-readable value attribute.
val var :
([< Html_types.var_attrib ],
[< Html_types.var_content_fun ],
[> Html_types.var ])
starval img :
src:Xml.uri wrap ->
alt:Html_types.text wrap ->
([< Html_types.img_attrib ], [> Html_types.img ]) nullaryval picture :
img:[< Html_types.img ] elt wrap ->
([< Html_types.picture_attrib ],
[< Html_types.picture_content_fun ],
[> Html_types.picture ])
starval iframe :
([< Html_types.iframe_attrib ],
[< Html_types.iframe_content_fun ],
[> Html_types.iframe ])
starval object_ :
?params:[< Html_types.param ] elt list_wrap ->
([< Html_types.object__attrib ], 'a, [> `Object of 'a ]) starval audio :
?src:Xml.uri wrap ->
?srcs:[< Html_types.source ] elt list_wrap ->
?tracks:[< Html_types.track ] elt list_wrap ->
([< Html_types.audio_attrib ], 'a, [> 'a Html_types.audio ]) starval video :
?src:Xml.uri wrap ->
?srcs:[< Html_types.source ] elt list_wrap ->
?tracks:[< Html_types.track ] elt list_wrap ->
([< Html_types.video_attrib ], 'a, [> 'a Html_types.video ]) starval area :
alt:Html_types.text wrap ->
([< Html_types.area_attrib ], [> Html_types.area ]) nullaryval caption :
([< Html_types.caption_attrib ],
[< Html_types.caption_content_fun ],
[> Html_types.caption ])
starval table :
?caption:[< Html_types.caption ] elt wrap ->
?columns:[< Html_types.colgroup ] elt list_wrap ->
?thead:[< Html_types.thead ] elt wrap ->
?tfoot:[< Html_types.tfoot ] elt wrap ->
([< Html_types.table_attrib ],
[< Html_types.table_content_fun ],
[> Html_types.table ])
starval tablex :
?caption:[< Html_types.caption ] elt wrap ->
?columns:[< Html_types.colgroup ] elt list_wrap ->
?thead:[< Html_types.thead ] elt wrap ->
?tfoot:[< Html_types.tfoot ] elt wrap ->
([< Html_types.tablex_attrib ],
[< Html_types.tablex_content_fun ],
[> Html_types.tablex ])
starval colgroup :
([< Html_types.colgroup_attrib ],
[< Html_types.colgroup_content_fun ],
[> Html_types.colgroup ])
starval thead :
([< Html_types.thead_attrib ],
[< Html_types.thead_content_fun ],
[> Html_types.thead ])
starval tbody :
([< Html_types.tbody_attrib ],
[< Html_types.tbody_content_fun ],
[> Html_types.tbody ])
starval tfoot :
([< Html_types.tfoot_attrib ],
[< Html_types.tfoot_content_fun ],
[> Html_types.tfoot ])
starval form :
([< Html_types.form_attrib ],
[< Html_types.form_content_fun ],
[> Html_types.form ])
starval fieldset :
?legend:[< Html_types.legend ] elt wrap ->
([< Html_types.fieldset_attrib ],
[< Html_types.fieldset_content_fun ],
[> Html_types.fieldset ])
starval legend :
([< Html_types.legend_attrib ],
[< Html_types.legend_content_fun ],
[> Html_types.legend ])
starval label :
([< Html_types.label_attrib ],
[< Html_types.label_content_fun ],
[> Html_types.label ])
starLabel 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
val button :
([< Html_types.button_attrib ],
[< Html_types.button_content_fun ],
[> Html_types.button ])
starval select :
([< Html_types.select_attrib ],
[< Html_types.select_content_fun ],
[> Html_types.select ])
starval datalist :
?children:
[< `Options of [< Html_types.selectoption ] elt list_wrap
| `Phras of [< Html_types.phrasing ] elt list_wrap ] ->
([< Html_types.datalist_attrib ], [> Html_types.datalist ]) nullaryval optgroup :
label:Html_types.text wrap ->
([< Html_types.optgroup_attrib ],
[< Html_types.optgroup_content_fun ],
[> Html_types.optgroup ])
starval option :
([< Html_types.option_attrib ],
[< Html_types.option_content_fun ],
[> Html_types.selectoption ])
unaryval textarea :
([< Html_types.textarea_attrib ],
[< Html_types.textarea_content_fun ],
[> Html_types.textarea ])
unaryval progress :
([< Html_types.progress_attrib ],
[< Html_types.progress_content_fun ],
[> Html_types.progress ])
starval meter :
([< Html_types.meter_attrib ],
[< Html_types.meter_content_fun ],
[> Html_types.meter ])
starval output_elt :
([< Html_types.output_elt_attrib ],
[< Html_types.output_elt_content_fun ],
[> Html_types.output_elt ])
starentity "foo" is the HTML entity &foo;. Both numerical and named form are allowed.
val details :
[< Html_types.summary ] elt wrap ->
([< Html_types.details_attrib ],
[< Html_types.details_content_fun ],
[> Html_types.details ])
starval summary :
([< Html_types.summary_attrib ],
[< Html_types.summary_content_fun ],
[> Html_types.summary ])
starval command :
label:Html_types.text wrap ->
([< Html_types.command_attrib ], [> Html_types.command ]) nullaryval script :
([< Html_types.script_attrib ],
[< Html_types.script_content_fun ],
[> Html_types.script ])
unaryval noscript :
([< Html_types.noscript_attrib ],
[< Html_types.noscript_content_fun ],
[> Html_types.noscript ])
starval template :
([< Html_types.template_attrib ],
[< Html_types.template_content_fun ],
[> Html_types.template ])
starval meta_itemprop :
itemprop:string list wrap ->
([< Html_types.meta_attrib ], [> Html_types.meta_with_itemprop ]) nullarymeta_itemprop ~itemprop () is a meta element annotating the surrounding microdata item. Unlike meta, it is phrasing content, so it is allowed in the body and not only in the head.
val style :
([< Html_types.style_attrib ],
[< Html_types.style_content_fun ],
[> Html_types.style ])
starval link :
rel:Html_types.linktypes wrap ->
href:Xml.uri wrap ->
([< Html_types.link_attrib ], [> Html_types.link ]) nullaryval ruby :
([< Html_types.ruby_attrib ],
[< Html_types.ruby_content_fun ],
[> Html_types.ruby ])
starWARNING: 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.