InterviewHubPRO
Section Overview
Q166

Question 166 of 521

Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

32%
JavaScript Internals (521 Qs)•Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

How do you change the style of a HTML element

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
  document.getElementById("title").style.fontSize = "30px";
  1. Using ClassName property: It is easy to modify element class using className property
javascript
  document.getElementById("title").className = "custom-title";