April 17, 2024, 7:15 a.m. | FatimaAlam1234

DEV Community dev.to

Q. How do you change the style of a HTML element

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


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

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

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

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

change class document easy element html interview interview questions javascript property questions style

Data Engineer

@ Lemon.io | Remote: Europe, LATAM, Canada, UK, Asia, Oceania

Artificial Intelligence – Bioinformatic Expert

@ University of Texas Medical Branch | Galveston, TX

Lead Developer (AI)

@ Cere Network | San Francisco, US

Research Engineer

@ Allora Labs | Remote

Ecosystem Manager

@ Allora Labs | Remote

Founding AI Engineer, Agents

@ Occam AI | New York