Reputation: 541
That would go like this * {margin:0; padding:0;} in CSS.
Upvotes: 2
Views: 1710
Reputation: 17831
To get the (first) stylesheet object use
document.styleSheets[0]
To access the (first) rule in the stylesheet use on of:
document.styleSheets[0].cssRules[0] // firefox
document.styleSheets[0].rules[0] // IE
You can add rules with
insertRule(rule, index) // firefox
addRule(selector, declaration, [index]) // IE
Thus, to do what you describe in firefox:
document.styleSheets[0].insertRule("*{margin:0; padding:0;}", 0)
And to do it in IE:
document.styleSheets[0].addRule("*", "margin:0; padding:0;", 0)
See also: Dom StyleSheet Object.
Upvotes: 7
Reputation: 3859
If you'd like to change the padding and margin for the body element:
document.body.setAttribute('padding', '0');
document.body.setAttribute('margin', '0');
Upvotes: -1