← Back to CSS domain

CSS.getMatchedStylesForNode

Returns requested styles for a DOM node identified by `nodeId`.

Domain: CSS experimental

Parameters

NameTypeDescription
nodeIdDOM.NodeId

Returns

NameTypeDescription
inlineStyleCSSStyleInline style for the specified DOM node.
attributesStyleCSSStyleAttribute-defined element style (e.g. resulting from "width=20 height=100%").
matchedCSSRulesarrayCSS rules matching this node, from all applicable stylesheets.
pseudoElementsarrayPseudo style matches for this node.
inheritedarrayA chain of inherited styles (from the immediate node parent up to the DOM tree root).
inheritedPseudoElementsarrayA chain of inherited pseudo element styles (from the immediate node parent up to the DOM tree root).
cssKeyframesRulesarrayA list of CSS keyframed animations matching this node.
cssPositionTryRulesarrayA list of CSS @position-try rules matching this node, based on the position-try-fallbacks property.
activePositionFallbackIndexintegerIndex of the active fallback in the applied position-try-fallback property, will not be set if there is no active position-try fallback.
cssPropertyRulesarrayA list of CSS at-property rules matching this node.
cssPropertyRegistrationsarrayA list of CSS property registrations matching this node.
cssAtRulesarrayA list of simple @rules matching this node or its pseudo-elements.
parentLayoutNodeIdDOM.NodeIdId of the first parent element that does not have display: contents.
cssFunctionRulesarrayA list of CSS at-function rules referenced by styles of this node.

Example Request

{
  "id": 1,
  "method": "CSS.getMatchedStylesForNode",
  "params": {
    "nodeId": 1
  }
}

Example Response

{
  "id": 1,
  "result": {
    "inlineStyle": "inlineStyle-value",
    "attributesStyle": "attributesStyle-value",
    "matchedCSSRules": [],
    "pseudoElements": [],
    "inherited": [],
    "inheritedPseudoElements": [],
    "cssKeyframesRules": [],
    "cssPositionTryRules": [],
    "activePositionFallbackIndex": 1,
    "cssPropertyRules": [],
    "cssPropertyRegistrations": [],
    "cssAtRules": [],
    "parentLayoutNodeId": "parentLayoutNodeId-value",
    "cssFunctionRules": []
  }
}

Usage in Node.js

const result = await send('CSS.getMatchedStylesForNode', {"nodeId": 1});
console.log(result);
// {"inlineStyle": "inlineStyle-value", "attributesStyle": "attributesStyle-value", "matchedCSSRules": [], "pseudoElements": [], "inherited": [], "inheritedPseudoElements": [], "cssKeyframesRules": [], "cssPositionTryRules": [], "activePositionFallbackIndex": 1, "cssPropertyRules": [], "cssPropertyRegistrations": [], "cssAtRules": [], "parentLayoutNodeId": "parentLayoutNodeId-value", "cssFunctionRules": []}