← Back to CSS domain
CSS.getMatchedStylesForNode
Returns requested styles for a DOM node identified by `nodeId`.
Domain: CSS
experimental
Parameters
| Name | Type | Description |
nodeId | DOM.NodeId | |
Returns
| Name | Type | Description |
inlineStyle | CSSStyle | Inline style for the specified DOM node. |
attributesStyle | CSSStyle | Attribute-defined element style (e.g. resulting from "width=20 height=100%"). |
matchedCSSRules | array | CSS rules matching this node, from all applicable stylesheets. |
pseudoElements | array | Pseudo style matches for this node. |
inherited | array | A chain of inherited styles (from the immediate node parent up to the DOM tree root). |
inheritedPseudoElements | array | A chain of inherited pseudo element styles (from the immediate node parent up to the DOM tree root). |
cssKeyframesRules | array | A list of CSS keyframed animations matching this node. |
cssPositionTryRules | array | A list of CSS @position-try rules matching this node, based on the position-try-fallbacks property. |
activePositionFallbackIndex | integer | Index of the active fallback in the applied position-try-fallback property,
will not be set if there is no active position-try fallback. |
cssPropertyRules | array | A list of CSS at-property rules matching this node. |
cssPropertyRegistrations | array | A list of CSS property registrations matching this node. |
cssAtRules | array | A list of simple @rules matching this node or its pseudo-elements. |
parentLayoutNodeId | DOM.NodeId | Id of the first parent element that does not have display: contents. |
cssFunctionRules | array | A 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": []}