В качестве примера :-)
<div id="test"></div>
<script>
const buildElement = (tagName, props = {}, attributes = {}) => {
const el = Object.assign(document.createElement(tagName), props);
for (let key in attributes) el.setAttribute(key, attributes[key]);
return el;
}
const label = buildElement('label', {
className: 'form__label',
innerText: 'Best Label',
}, {
for: "formName",
onclick: "alert(this.tagName)"
});
test.insertAdjacentHTML('beforeend', label.outerHTML)
</script>