Easy way to remove inline styles
Published:
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
.