I want a list of all the CSS property names the browser understands.
Using an arbitrary CSSStyleDeclaration
object as follows does a pretty good job:
const styles = getComputedStyle(document.body);
const styleNames = Array.from(Array(styles.length), (_, i) => styles[i])
styleNames // Array(370) [ "accent-color", "align-content", "align-items", "align-self",
// "animation-composition", "animation-delay", "animation-direction", "animation-duration",
// "animation-fill-mode", "animation-iteration-count", … ]
However, this doesn’t include any shorthand styles. Even though the CSSStyleDeclaration
object can understand shorthand properties when it’s queried for them (e.g. styles["margin"]
), I have been unable to find a way to retrieve these keys. How can I do this?