Example 3: Manipulating Styles
In this simple example, some basic style properties of an HTML paragraph element are accessed using the style object on the element and that object's CSS style properties, which can be retrieved and set from the DOM. In this case, you are manipulating the individual styles directly. In the next example (see Example 4), you can use stylesheets and their rules to change styles for whole documents.
<html>
<head>
<script>
function changeText() {
p = document.getElementById("pid");
p.style.color = "blue"
p.style.fontSize = "18pt"
}
</script>
</head>
<body>
<p id="pid"
onclick="window.location='http://www.cnn.com';" >linker</p>
<form>
<input value="rec" type="button" onclick="changeText();" />
</form>
</body>
</html>