I often use the CSS universal selector to reset the dimensions in my HTML document:
* {
border: 0;
margin: 0;
padding: 0;
}
Can this be done with JavaScript too?
For normal HTML elements there is the style
property.
But how to speak to the universal selector?
getElementsByTagName("*")
will return all elements from DOM. Then you may set styles for each element in the collection:
var allElements = document.getElementsByTagName("*");
for (var i = 0, len = allElements.length; i < len; i++) {
var element = allElements[i];
// element.style.border = ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With