JS Coding Questions Logo
JS Coding Questions
#162💼 Interview💻 Code

How do you change the style of a HTML element

Advertisement

728x90

You can change inline style or classname of a HTML element using javascript DOM-manipulation

1. Using style property: You can modify inline style using style property

javascript
1document.getElementById("title").style.fontSize = "30px";

2. Using ClassName property: It is easy to modify element class using className property

javascript
1document.getElementById("title").className = "custom-title";

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 77

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
162of476