codice:
document.getElementsByTagName("div")[0].style.color='red';
considera che getElementsByTagName ritorna un array di elementi, non un singolo elemento come fa getElementById.

saluti