Helper for generate HTML5 element.
html5(tag = 'doctype', attributes = {}, ...children): stringThe HTML5 tag.
The HTML5 attributes.
The HTML5 children.
Return the HTML5 element.
Example #1: Basic example
const html =
html5('div', {'class': 'row'},
html5('div', {'class': ['col-sm-8', 'col-md-6']}, '')
)
console.log(html)<div class="row">
<div class="col-sm-8 col-md-6"></div>
</div>Example #2: Doctype declaration
console.log(html5())<!DOCTYPE html>Example #3: Multiple children
const html =
html5('ul', {},
html5('li', {}, ''),
html5('li', {}, '')
)
console.log(html)<ul>
<li></li>
<li></li>
</ul>Example #4: Self-closing tags
const html =
html5('input', {
'required': true,
'style': {
'display': 'block'
},
'type': 'text'
})
console.log(html)<input required style="display:block;" type="text">