Html

Node

An HTML node, either an HTML element or some text inside an HTML element.

text : Str -> Node

Create a Text node containing a string.

The string will be escaped so that it's safely rendered as a text node even if the string contains HTML tags.

expect
    textNode = Html.text "<script>alert('hi')</script>"
    Html.renderWithoutDocType textNode == "&lt;script&gt;alert(&#39;hi&#39;)&lt;/script&gt;"

dangerouslyIncludeUnescapedHtml : Str -> Node

Mark a string as safe for HTML without actually escaping it.

DO NOT use this function unless you're sure the input string is safe.

NEVER use this function on user input; use the text function instead.

expect
    htmlNode = Html.dangerouslyIncludeUnescapedHtml "<script>alert('This JavaScript will run')</script>"
    Html.renderWithoutDocType htmlNode ==  "<script>alert('This JavaScript will run')</script>"

element : Str -> List Attribute, List Node -> Node

Define a non-standard HTML element. You can use this to add elements that are not already supported.

For example, you could bring back the obsolete <blink> element and add some 90's nostalgia to your web page!

blink : List Attribute, List Node -> Node
blink = element "blink"

blink [] [ text "This text is blinking!" ]

voidElement : Str -> List Attribute -> Node

Define a non-standard HTML void element. A void element is an element that cannot have any children.

render : Node -> Str

Render a Node to an HTML string

The output has no whitespace between nodes, to make it small. This is intended for generating full HTML documents, so it automatically adds to the start of the string. See also renderWithoutDocType.

renderWithoutDocType : Node -> Str

Render a Node to a string, without a !DOCTYPE tag.

address : List Attribute, List Node -> Node

Construct a address element.

article : List Attribute, List Node -> Node

Construct a article element.

aside : List Attribute, List Node -> Node

Construct a aside element.

footer : List Attribute, List Node -> Node

Construct a footer element.

h1 : List Attribute, List Node -> Node

Construct a h1 element.

h2 : List Attribute, List Node -> Node

Construct a h2 element.

h3 : List Attribute, List Node -> Node

Construct a h3 element.

h4 : List Attribute, List Node -> Node

Construct a h4 element.

h5 : List Attribute, List Node -> Node

Construct a h5 element.

h6 : List Attribute, List Node -> Node

Construct a h6 element.

header : List Attribute, List Node -> Node

Construct a header element.

main : List Attribute, List Node -> Node

Construct a main element.

nav : List Attribute, List Node -> Node

Construct a nav element.

section : List Attribute, List Node -> Node

Construct a section element.

del : List Attribute, List Node -> Node

Construct a del element.

ins : List Attribute, List Node -> Node

Construct a ins element.

base : List Attribute -> Node

Construct a base element.

head : List Attribute, List Node -> Node

Construct a head element.

link : List Attribute -> Node

Construct a link element.

meta : List Attribute -> Node

Construct a meta element.

style : List Attribute, List Node -> Node

Construct a style element.

title : List Attribute, List Node -> Node

Construct a title element.

embed : List Attribute -> Node

Construct a embed element.

iframe : List Attribute, List Node -> Node

Construct a iframe element.

object : List Attribute, List Node -> Node

Construct a object element.

picture : List Attribute, List Node -> Node

Construct a picture element.

portal : List Attribute, List Node -> Node

Construct a portal element.

source : List Attribute -> Node

Construct a source element.

button : List Attribute, List Node -> Node

Construct a button element.

datalist : List Attribute, List Node -> Node

Construct a datalist element.

fieldset : List Attribute, List Node -> Node

Construct a fieldset element.

form : List Attribute, List Node -> Node

Construct a form element.

input : List Attribute -> Node

Construct a input element.

label : List Attribute, List Node -> Node

Construct a label element.

legend : List Attribute, List Node -> Node

Construct a legend element.

meter : List Attribute, List Node -> Node

Construct a meter element.

optgroup : List Attribute, List Node -> Node

Construct a optgroup element.

option : List Attribute, List Node -> Node

Construct a option element.

output : List Attribute, List Node -> Node

Construct a output element.

progress : List Attribute, List Node -> Node

Construct a progress element.

select : List Attribute, List Node -> Node

Construct a select element.

textarea : List Attribute, List Node -> Node

Construct a textarea element.

area : List Attribute -> Node

Construct a area element.

audio : List Attribute, List Node -> Node

Construct a audio element.

img : List Attribute -> Node

Construct a img element.

map : List Attribute, List Node -> Node

Construct a map element.

track : List Attribute -> Node

Construct a track element.

video : List Attribute, List Node -> Node

Construct a video element.

a : List Attribute, List Node -> Node

Construct a a element.

abbr : List Attribute, List Node -> Node

Construct a abbr element.

b : List Attribute, List Node -> Node

Construct a b element.

bdi : List Attribute, List Node -> Node

Construct a bdi element.

bdo : List Attribute, List Node -> Node

Construct a bdo element.

br : List Attribute -> Node

Construct a br element.

cite : List Attribute, List Node -> Node

Construct a cite element.

code : List Attribute, List Node -> Node

Construct a code element.

data : List Attribute, List Node -> Node

Construct a data element.

dfn : List Attribute, List Node -> Node

Construct a dfn element.

em : List Attribute, List Node -> Node

Construct a em element.

i : List Attribute, List Node -> Node

Construct a i element.

kbd : List Attribute, List Node -> Node

Construct a kbd element.

mark : List Attribute, List Node -> Node

Construct a mark element.

q : List Attribute, List Node -> Node

Construct a q element.

rp : List Attribute, List Node -> Node

Construct a rp element.

rt : List Attribute, List Node -> Node

Construct a rt element.

ruby : List Attribute, List Node -> Node

Construct a ruby element.

s : List Attribute, List Node -> Node

Construct a s element.

samp : List Attribute, List Node -> Node

Construct a samp element.

small : List Attribute, List Node -> Node

Construct a small element.

span : List Attribute, List Node -> Node

Construct a span element.

strong : List Attribute, List Node -> Node

Construct a strong element.

sub : List Attribute, List Node -> Node

Construct a sub element.

sup : List Attribute, List Node -> Node

Construct a sup element.

time : List Attribute, List Node -> Node

Construct a time element.

u : List Attribute, List Node -> Node

Construct a u element.

var : List Attribute, List Node -> Node

Construct a var element.

wbr : List Attribute -> Node

Construct a wbr element.

details : List Attribute, List Node -> Node

Construct a details element.

dialog : List Attribute, List Node -> Node

Construct a dialog element.

summary : List Attribute, List Node -> Node

Construct a summary element.

html : List Attribute, List Node -> Node

Construct a html element.

math : List Attribute, List Node -> Node

Construct a math element.

svg : List Attribute, List Node -> Node

Construct a svg element.

canvas : List Attribute, List Node -> Node

Construct a canvas element.

noscript : List Attribute, List Node -> Node

Construct a noscript element.

script : List Attribute, List Node -> Node

Construct a script element.

body : List Attribute, List Node -> Node

Construct a body element.

caption : List Attribute, List Node -> Node

Construct a caption element.

col : List Attribute -> Node

Construct a col element.

colgroup : List Attribute, List Node -> Node

Construct a colgroup element.

table : List Attribute, List Node -> Node

Construct a table element.

tbody : List Attribute, List Node -> Node

Construct a tbody element.

td : List Attribute, List Node -> Node

Construct a td element.

tfoot : List Attribute, List Node -> Node

Construct a tfoot element.

th : List Attribute, List Node -> Node

Construct a th element.

thead : List Attribute, List Node -> Node

Construct a thead element.

tr : List Attribute, List Node -> Node

Construct a tr element.

blockquote : List Attribute, List Node -> Node

Construct a blockquote element.

dd : List Attribute, List Node -> Node

Construct a dd element.

div : List Attribute, List Node -> Node

Construct a div element.

dl : List Attribute, List Node -> Node

Construct a dl element.

dt : List Attribute, List Node -> Node

Construct a dt element.

figcaption : List Attribute, List Node -> Node

Construct a figcaption element.

figure : List Attribute, List Node -> Node

Construct a figure element.

hr : List Attribute -> Node

Construct a hr element.

li : List Attribute, List Node -> Node

Construct a li element.

menu : List Attribute, List Node -> Node

Construct a menu element.

ol : List Attribute, List Node -> Node

Construct a ol element.

p : List Attribute, List Node -> Node

Construct a p element.

pre : List Attribute, List Node -> Node

Construct a pre element.

ul : List Attribute, List Node -> Node

Construct a ul element.

slot : List Attribute, List Node -> Node

Construct a slot element.

template : List Attribute, List Node -> Node

Construct a template element.