ZL
About Articles Contact
Published on Apr 17, 2024
Filed under:
#css

Easy way to remove inline styles

Here’s a simple way to remove inline styles from 3rd-party libraries.

// Replace .container with the HTML element you're targeting
const container = document.querySelector('.container')
const elements = container.querySelectorAll('*')
for (const element of elements) {
element.removeAttribute('style')
}

The basic idea is we strip out the style tag from all elements within the container, so you don’t have to fight a never-winning CSS specificity war by using !important.

Previous Best Practice for Astro Endpoints Next Understanding Recursion in JavaScript

Join My Newsletter

I share what I’m learning on this newsletter: code, building businesses, and living well.

Sometimes I write about technical deep-dives, product updates, musings on how to live, and sometimes my struggles and how I’m breaking through.

Regardless of the type of content, I do my best to send you an update every week.

If you’re into making things and growing as a person, you’ll probably feel at home here.

“

Zell’s writing is very accessible to newcomers because he shares his learning experience. He covers current topics and helps all readers level up their web development skills. Must subscribe.

Chen Hui Jing
Chen Hui Jing — Web Developer
The Footer

General

Home About Contact Testimonials Tools I Use

Projects

Magical Dev School Splendid Labz

Socials

Youtube Instagram Tiktok Github Bluesky X

Follow Along

Email RSS
© 2013 - 2025 Zell Liew / All rights reserved / Terms