Check out the various JavaScript libraries. I recommend jQuery, check out the tutorial.
Then it's easy to add style (not really a class unless it already exists in the CSS):
<script>
$(document).ready(function() {
// add 'style="height:30px;"' to the div with id="foo".
$('#foo').attr("style", {height: "30px"})
});
</script>
Or add the same style to all elements with class="bar"
:
<script>
$(document).ready(function() {
// add 'style="height:30px;"' to all elements with class="bar".
$('.bar').attr("style", {height: "30px"})
});
</script>
If you want to create new CSS classes at run-time try: jQuery.Rule