Skip to main content
InterviewHubPRO
Section Overview
Q166

Question 166 of 536

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

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

How do you change the style of a HTML element

mid LevelCode ExampleHTTP & REST APIs

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";