asked 157k views
5 votes
Write and register an event handler that changes the font size of the h1 tag to 35 on click.

a) JavaScript
b) HTML
c) CSS
d) Python

1 Answer

3 votes

Final answer:

To change the font size of an h1 tag to 35px on click, you need to add an event listener in JavaScript that modifies the CSS font-size property when the h1 tag is clicked.

Step-by-step explanation:

To write and register an event handler that changes the font size of the h1 tag to 35px on click, you need to use a combination of HTML, CSS, and JavaScript. First set up your HTML structure with an h1 tag. Next, include JavaScript to add the event handler to the h1 element. Here is a simple example:

HTML

:

<h1 id="header">Click me!</h1>

JavaScript

:

document.getElementById('header').addEventListener('click', function() {
this.style.fontSize = '35px';
});

The JavaScript code grabs the element with the ID 'header' and adds a click event listener that changes its font size to 35px when clicked.

answered
User Ehbello
by
8.8k points