The CSSStyleDeclaration object represents a collection of CSS property-value pairs.
It is used in API :
setProperty(property, value, priority)
The style property is used to get or set the inline style of an element. While getting, it returns a CSSStyleDeclaration object that contains a list of all styles properties for that element with values assigned for the attributes that are defined in the element’s inline style attribute.
Style Property represents only the CSS declarations set in the element’s inline style attribute, not those that come from style rules elsewhere, such as style rules in the <head> section, or external style sheets or browser default.
element.style.property = “value”
A style declaration is reset by setting it to null or an empty string, e.g. element.style.property = null
Inline Style Manipulation
Dynamic Style Manipulation
The Element.classList is a read-only property that returns a live DOMTokenList collection of the class attributes of the element.
var elementClasses = elementNodeReference.classList;
The computed style is the style actually used in displaying the element, after “stylings” from multiple sources have been applied.
Style sources can include: internal style sheets, external style sheets, inherited styles, and browser default styles.
Style Property represents only the CSS declarations set in the element’s inline style attribute, not those that come from style rules elsewhere, such as style rules in the section, or external style sheets or browser default. To get the values of all CSS properties for an element you should use window.getComputedStyle( ) instead.
The returned style is a live CSSStyleDeclaration object ( The CSSStyleDeclaration object represents a collection of CSS property-value pairs.), which updates itself automatically when the element’s style is changed.
Element – Element for which to get the computed style.
pseudoElement – A string specifying the pseudo-element to match. Must be omitted (or null) for regular elements.
var elm = document.getElementById(“myid”);
var allCSSProp = window.getComputedStyle(elm)