Javascript: Change Style

Javascript can change the style of an element:

HTML file: Displayed by browser:
<!DOCTYPE html>
<html>
<body>

<h1>My First JavaScript</h1>

<p id="demo">JavaScript can change the style of an HTML element.</p>

<script>
function myFunction() {
    document.getElementById("demo").style.fontSize = "25px";
}
</script>

<button type="button" onclick="myFunction()">Click Me!</button>

</body>
</html>

My First JavaScript

JavaScript can change the style of an HTML element.


Back button Table of Contents Next button