Search code examples
javascriptcssdefault-value

is there a list of default values of css properties ? (so I can make an exclusion array in js for them)


All sites that list css properties such like MDN or w3schools list every CSS property on separate pages.

When I'm iterating over CSSStyleDeclaration I get bunch of data that 90% of it are default values. Now I have not found another way of checking these values than to go to every page and look and then create my exclusion array so when looping over the object I can filter out not touched values.

But if it were a list somewhere I could copy it and do it a lot quicker than manually looking on every page.

(I assume there is no programatic way of checking from JS if given value is default, I can be almost sure that if it say none or auto or normal or 0px it is the default but this is not certain way of doing it)


Solution

  • The specifications define initial values, i.e. the values to be used in the absence of any stylesheet or equivalent. The default values, in the sense of values used in the absence of any author stylesheet (= page stylesheet), are implementation-dependent. They depend on browsers (conceptually, on browser default stylesheets) and on their settings (user stylesheets or browser settings).

    Finding out the initial values is just raw work, but you shouldn’t expect them to be default values. There doesn’t seem to be any way to programmatically find out the default values. For a specific browser, you might be able to locate its default stylesheet or its description, but they would tell you just the “factory defaults.”