element {
border-color: #000;
font-family: serif;
}
element.style.borderColor = "#000";
element.style.fontFamily = "serif";
Just because you can change styles, doesn't mean you should.
CSS for presentation, DOM Scripting for behaviour.
But you can make up for deficiencies in browser support for CSS.
Where possible, instead of updating an element's styles directly, give it a class instead. Then style the class in your CSS file.
className
element.className = "myclass"
Adding classes to a document when it would be too tedious to do it by hand.
Style every second row in a table.
On a page of FAQs, only display the answer that the user requests.
Animation!
Used to be called DHTML.