document.getElementById(dCon.id).appendChild(pString)
document.getElementById(dCon.id).appendChild(pString).appendChild(blink)
document.getElementById(dCon.id).appendChild(pString); pString.appendChild(blink);
<style> div, span{ outline: 1px solid red; padding: 5px; display: inline-block; } #dCon:before{ content: attr(id); } .pString:before, .blink:before{ content: attr(class); } </style> <body> <script> var dCon = document.createElement('span'); dCon.id = 'dCon'; document.body.appendChild(dCon); var pString = document.createElement('span'); pString.className = 'pString'; var blink = document.createElement('span'); blink.className = 'blink'; document.getElementById(dCon.id).appendChild(pString).appendChild(blink); </script>