Module Webs_html.At

HTML element attributes.


type name = string

The type for attribute names.

module Name : sig ... end

Attribute names.


type t

The type for attributes.

val v : name -> string -> t

v n value is an attribute named n with value value.

See also (and favor) attribute constructors.

val void : t

void is an attribute that doesn't get rendered. This is v "" "".

val is_void : t -> bool

is_void a is true iff a is void.

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.

val int : name -> int -> t

int n i is v n (string_of_int i).

val if' : bool -> t -> t

if' b a is a if b is true and void otherwise.

val if_some : name -> string option -> t

if_some n o is v n value if o is Some value and void if o is None.

FIXME if void works well remove the add_if's. There are a bit unconvient to use.

val add_if : bool -> t -> t list -> t list

add_if c att atts is att :: atts if c is true and atts otherwise.

val add_if_some : name -> string option -> t list -> t list

add_if_some n o atts is (v n value) :: atts if o is Some value and atts otherwise.

val to_pair : t -> string * string

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


See the MDN HTML attribute reference.

Convention. Whenever an attribute name conflicts with an OCaml keyword we prime it, see for example class'.

type 'a cons = 'a -> t

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

val accesskey : string cons
val action : string cons
val autocomplete : string cons
val autofocus : t
val charset : string cons
val checked : t
val class' : string cons
val content : string cons
val contenteditable : bool cons
val cols : int cons
val defer : t
val disabled : t
val dir : string cons
val draggable : bool cons
val for' : string cons
val height : int cons
val href : string cons
val hidden : t
val id : string cons
val lang : string cons
val media : string cons
val name : string cons
val method' : string cons
val placeholder : string cons
val rel : string cons
val required : t
val rows : int cons
val spellcheck : string cons
val selected : t
val src : 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