Skip to content

arxcode40/html5-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTML5 JS

Description

Helper for generate HTML5 element.

Syntax

html5(tag = 'doctype', attributes = {}, ...children): string

Parameters

tag

The HTML5 tag.

attributes

The HTML5 attributes.

children

The HTML5 children.

Return Values

Return the HTML5 element.

Examples

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">

About

Generate HTML5 element using JavaScript

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors