var block = document.querySelectorAll('#block')[0]; block.innerHTML = '<div class="test">test</div>'; var elem = document.querySelectorAll('.test')[0]; elem.cssText = 'color: red;';