In the following code, the div "main" switches from class "main1" to "main2". Testing demonstrates that the new class is applied (size changes from 100x200 to 200x100), however the new class does not override the background-color assigned previsouly to the div. Is this the normal behavior?
<!DOCTYPE html>
<html>
<head>
<style>
.main1 {width:100px; height:200px; background-color:yellow;}
.main2 {width:200px; height:100px; background-color:orange;}
</style>
<script>
function start() {
document.getElementById("main").style.backgroundColor = "green";
document.getElementById("main").className = "main2";
}
</script>
</head>
<body onload="start();">
<div id="main" class="main1"></div>
</body>
</html>