// Create a temporary <div> to load into var div = document.createElement('div'); div.setAttribute('class', 'someClass'); div.innerHTML = document.getElementById('blockOfStuff').innerHTML; // You could optionally even do a little bit of string templating div.innerHTML = div.innerHTML .replace(/{VENDOR}/g, 'ACME Inc.') .replace(/{PRODUCT}/g, 'Best TNT') .replace(/{PRICE}/g, '$1.49'); // Write the <div> to the HTML container document.getElementById('targetElement').appendChild(div);