package htmlit

  1. Overview
  2. Docs

HTML attributes.

See the attribute constructors.

Attributes

type name = string

The type for attribute names.

type t

The type for attributes.

val v : name -> string -> t

v n value is an attribute named n with value value. Favour use of attribute constructors whenever possible.

val void : t

void is v "" "", an attribute that doesn't get rendered. See also is_void.

val int : name -> int -> t

int n i is v n (string_of_int i).

val true' : name -> t

true' n is v n "". This sets the boolean attribute n to true. The attribute must be omitted to be false. See also if' and if_some.

val if' : bool -> t -> t

if' cond at is if cond then at else void.

val if_some : t option -> t

if_some o is at if o is Some at and void if o is None.

Predicates and comparisons

val is_void : t -> bool

is_void at is true iff the name of at is empty. These attributes render nothing. See also void.

val equal : t -> t -> bool

equal at0 at1 is true if both the name and value of at0 and at1 are String.equal.

val compare : t -> t -> int

compare is a total order on attributes compatible with equal.

Converting and formatting

val to_pair : t -> string * string

to_pair at is (n, v) the name and value of the attribute.

val of_pair : (string * string) -> t

of_pair (n, value) is v n value.

val pp : Format.formatter -> t -> unit

pp ppf at formats at on ppf using HTML syntax. is_void attributes format nothing.

Attribute constructors

See the MDN HTML attribute reference.

type 'a cons = 'a -> t

The type for attribute constructors with attribute values of type 'a.

val accesskey : string cons
val action : string cons
val alt : string cons
val autocomplete : string cons
val autofocus : t
val charset : string cons
val checked : t
val class' : string cons
val cols : int cons
val colspan : int cons
val content : string cons
val contenteditable : bool cons
val datetime : string cons
val defer : t
val dir : string cons
val disabled : t
val draggable : bool cons
val for' : string cons
val height : int cons
val hidden : t
val href : string cons
val id : string cons
val lang : string cons
val list : string cons
val media : string cons
val method' : string cons
val name : string cons
val placeholder : string cons
val rel : string cons
val required : t
val rows : int cons
val rowspan : int cons
val selected : t
val spellcheck : string cons
val src : string cons
val style : string cons
val tabindex : int cons
val title : string cons
val type' : string cons
val value : string cons
val wrap : string cons
val width : int cons
OCaml

Innovation. Community. Security.