https://github.com/arxcode40/html5-js
Generate HTML5 element using JavaScript
https://github.com/arxcode40/html5-js
html html5 javascript
Last synced: about 1 year ago
JSON representation
Generate HTML5 element using JavaScript
- Host: GitHub
- URL: https://github.com/arxcode40/html5-js
- Owner: arxcode40
- License: mit
- Created: 2025-01-28T07:21:29.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-29T08:47:05.000Z (about 1 year ago)
- Last Synced: 2025-01-29T09:38:01.136Z (about 1 year ago)
- Topics: html, html5, javascript
- Language: JavaScript
- Homepage:
- Size: 1000 Bytes
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HTML5 JS
## Description
Helper for generate HTML5 element.
## Syntax
```javascript
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**
```javascript
const html =
html5('div', {'class': 'row'},
html5('div', {'class': ['col-sm-8', 'col-md-6']}, '')
)
console.log(html)
```
```html
```
**Example #2: Doctype declaration**
```javascript
console.log(html5())
```
```html
```
**Example #3: Multiple children**
```javascript
const html =
html5('ul', {},
html5('li', {}, ''),
html5('li', {}, '')
)
console.log(html)
```
```html
```
**Example #4: Self-closing tags**
```javascript
const html =
html5('input', {
'required': true,
'style': {
'display': 'block'
},
'type': 'text'
})
console.log(html)
```
```html
```