stable (1.2) latest (tip-of-tree) v8-inspector (node) Home Domains Accessibility Animation ApplicationCache CSS CacheStorage Console DOM DOMDebugger DOMStorage Database Debugger DeviceOrientation Emulation HeapProfiler IO IndexedDB Input Inspector LayerTree Log Memory Network Page Profiler Rendering Runtime Schema Security ServiceWorker Storage SystemInfo Target Tethering Tracing
Chrome Debugging Protocol Viewer - latest (tip-of-tree)

CSS Domain

This domain exposes CSS read/write operations. All CSS objects (stylesheets, rules, and styles) have an associated id used in subsequent operations on the related object. Each object type has a specific id structure, and those are not interchangeable between objects of different kinds. CSS objects can be loaded using the get*ForNode() calls (which accept a DOM node id). A client can also discover all the existing stylesheets with the getAllStyleSheets() method (or keeping track of the styleSheetAdded/styleSheetRemoved events) and subsequently load the required stylesheet contents using the getStyleSheet[Text]() methods.

Experimental

Methods

CSS. enable

Enables the CSS agent for the given page. Clients should not assume that the CSS agent has been enabled until the result of this command is received.

CSS. disable

Disables the CSS agent for the given page.

CSS. getMatchedStylesForNode

Returns requested styles for a DOM node identified by nodeId.

Parameters
nodeId
DOM.NodeId
Return object
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 [ RuleMatch ] CSS rules matching this node, from all applicable stylesheets.
pseudoElements
array [ PseudoElementMatches ] Pseudo style matches for this node.
inherited
array [ InheritedStyleEntry ] A chain of inherited styles (from the immediate node parent up to the DOM tree root).
cssKeyframesRules
array [ CSSKeyframesRule ] A list of CSS keyframed animations matching this node.

CSS. getInlineStylesForNode

Returns the styles defined inline (explicitly in the "style" attribute and implicitly, using DOM attributes) for a DOM node identified by nodeId.

Parameters
nodeId
DOM.NodeId
Return object
inlineStyle
CSSStyle Inline style for the specified DOM node.
attributesStyle
CSSStyle Attribute-defined element style (e.g. resulting from "width=20 height=100%").

CSS. getComputedStyleForNode

Returns the computed style for a DOM node identified by nodeId.

Parameters
nodeId
DOM.NodeId
Return object
computedStyle
array [ CSSComputedStyleProperty ] Computed style for the specified DOM node.

CSS. getPlatformFontsForNode

Requests information about platform fonts which we used to render child TextNodes in the given node. Experimental

Parameters
nodeId
DOM.NodeId
Return object
fonts
array [ PlatformFontUsage ] Usage statistics for every employed platform font.

CSS. getStyleSheetText

Returns the current textual content and the URL for a stylesheet.

Parameters
styleSheetId
StyleSheetId
Return object
text
string The stylesheet text.

CSS. collectClassNames

Returns all class names from specified stylesheet. Experimental

Parameters
styleSheetId
StyleSheetId
Return object
classNames
array [string] Class name list.

CSS. setStyleSheetText

Sets the new stylesheet text.

Parameters
styleSheetId
StyleSheetId
text
string
Return object
sourceMapURL
string URL of source map associated with script (if any).

CSS. setRuleSelector

Modifies the rule selector.

Parameters
styleSheetId
StyleSheetId
range
SourceRange
selector
string
Return object
selectorList
SelectorList The resulting selector list after modification.

CSS. setKeyframeKey

Modifies the keyframe rule key text.

Parameters
styleSheetId
StyleSheetId
range
SourceRange
keyText
string
Return object
keyText
Value The resulting key text after modification.

CSS. setStyleTexts

Applies specified style edits one after another in the given order.

Parameters
edits
array [ StyleDeclarationEdit ]
Return object
styles
array [ CSSStyle ] The resulting styles after modification.

CSS. setMediaText

Modifies the rule selector.

Parameters
styleSheetId
StyleSheetId
range
SourceRange
text
string
Return object
media
CSSMedia The resulting CSS media rule after modification.

CSS. createStyleSheet

Creates a new special "via-inspector" stylesheet in the frame with given frameId.

Parameters
frameId
Page.FrameId Identifier of the frame where "via-inspector" stylesheet should be created.
Return object
styleSheetId
StyleSheetId Identifier of the created "via-inspector" stylesheet.

CSS. addRule

Inserts a new rule with the given ruleText in a stylesheet with given styleSheetId, at the position specified by location.

Parameters
styleSheetId
StyleSheetId The css style sheet identifier where a new rule should be inserted.
ruleText
string The text of a new rule.
location
SourceRange Text position of a new rule in the target style sheet.
Return object
rule
CSSRule The newly created rule.

CSS. forcePseudoState

Ensures that the given node will have specified pseudo-classes whenever its style is computed by the browser.

Parameters
nodeId
DOM.NodeId The element id for which to force the pseudo state.
forcedPseudoClasses
array [string] Element pseudo classes to force when computing the element's style.
Array element:
Allowed values: active, focus, hover, visited.

CSS. getMediaQueries

Returns all media queries parsed by the rendering engine. Experimental

Return object
medias
array [ CSSMedia ]

CSS. setEffectivePropertyValueForNode

Find a rule with the given active property for the given node and set the new value for this property Experimental

Parameters
nodeId
DOM.NodeId The element id for which to set property.
propertyName
string
value
string

CSS. getBackgroundColors

Experimental

Parameters
nodeId
DOM.NodeId Id of the node to get background colors for.
Return object
backgroundColors
array [string] The range of background colors behind this element, if it contains any visible text. If no visible text is present, this will be undefined. In the case of a flat background color, this will consist of simply that color. In the case of a gradient, this will consist of each of the color stops. For anything more complicated, this will be an empty array. Images will be ignored (as if the image had failed to load).

CSS. getLayoutTreeAndStyles

For the main document and any content documents, return the LayoutTreeNodes and a whitelisted subset of the computed style. It only returns pushed nodes, on way to pull all nodes is to call DOM.getDocument with a depth of -1. Experimental

Parameters
computedStyleWhitelist
array [string] Whitelist of computed styles to return.
Return object
layoutTreeNodes
array [ LayoutTreeNode ]
computedStyles
array [ ComputedStyle ]

CSS. startRuleUsageTracking

Enables the selector recording. Experimental

CSS. takeCoverageDelta

Obtain list of rules that became used since last call to this method (or since start of coverage instrumentation) Experimental

Return object
coverage
array [ RuleUsage ]

CSS. stopRuleUsageTracking

The list of rules with an indication of whether these were used Experimental

Return object
ruleUsage
array [ RuleUsage ]

Events

CSS. mediaQueryResultChanged

Fires whenever a MediaQuery result changes (for example, after a browser window has been resized.) The current implementation considers only viewport-dependent media features.

CSS. fontsUpdated

Fires whenever a web font gets loaded.

CSS. styleSheetChanged

Fired whenever a stylesheet is changed as a result of the client operation.

Parameters
styleSheetId
StyleSheetId

CSS. styleSheetAdded

Fired whenever an active document stylesheet is added.

Parameters
header
CSSStyleSheetHeader Added stylesheet metainfo.

CSS. styleSheetRemoved

Fired whenever an active document stylesheet is removed.

Parameters
styleSheetId
StyleSheetId Identifier of the removed stylesheet.

Types

StyleSheetId

Type: string

StyleSheetOrigin

Stylesheet type: "injected" for stylesheets injected via extension, "user-agent" for user-agent stylesheets, "inspector" for stylesheets created by the inspector (i.e. those holding the "via inspector" rules), "regular" for regular stylesheets.

Type: string

Allowed values

injected, user-agent, inspector, regular.

PseudoElementMatches

CSS rule collection for a single pseudo style.

Type: object

Properties
pseudoType
DOM.PseudoType Pseudo element type.
matches
array [ RuleMatch ] Matches of CSS rules applicable to the pseudo style.

InheritedStyleEntry

Inherited CSS rule collection from ancestor node.

Type: object

Properties
inlineStyle
CSSStyle The ancestor node's inline style, if any, in the style inheritance chain.
matchedCSSRules
array [ RuleMatch ] Matches of CSS rules matching the ancestor node in the style inheritance chain.

RuleMatch

Match data for a CSS rule.

Type: object

Properties
rule
CSSRule CSS rule in the match.
matchingSelectors
array [integer] Matching selector indices in the rule's selectorList selectors (0-based).

Value

Data for a simple selector (these are delimited by commas in a selector list).

Type: object

Properties
text
string Value text.
range
SourceRange Value range in the underlying resource (if available).

SelectorList

Selector list data.

Type: object

Properties
selectors
array [ Value ] Selectors in the list.
text
string Rule selector text.

CSSStyleSheetHeader

CSS stylesheet metainformation.

Type: object

Properties
styleSheetId
StyleSheetId The stylesheet identifier.
frameId
Page.FrameId Owner frame identifier.
sourceURL
string Stylesheet resource URL.
sourceMapURL
string URL of source map associated with the stylesheet (if any).
origin
StyleSheetOrigin Stylesheet origin.
title
string Stylesheet title.
ownerNode
DOM.BackendNodeId The backend id for the owner node of the stylesheet.
disabled
boolean Denotes whether the stylesheet is disabled.
hasSourceURL
boolean Whether the sourceURL field value comes from the sourceURL comment.
isInline
boolean Whether this stylesheet is created for STYLE tag by parser. This flag is not set for document.written STYLE tags.
startLine
number Line offset of the stylesheet within the resource (zero based).
startColumn
number Column offset of the stylesheet within the resource (zero based).
length
number Size of the content (in characters). Experimental

CSSRule

CSS rule representation.

Type: object

Properties
styleSheetId
StyleSheetId The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
selectorList
SelectorList Rule selector data.
origin
StyleSheetOrigin Parent stylesheet's origin.
style
CSSStyle Associated style declaration.
media
array [ CSSMedia ] Media list array (for rules involving media queries). The array enumerates media queries starting with the innermost one, going outwards.

RuleUsage

CSS coverage information. Experimental

Type: object

Properties
styleSheetId
StyleSheetId The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
startOffset
number Offset of the start of the rule (including selector) from the beginning of the stylesheet.
endOffset
number Offset of the end of the rule body from the beginning of the stylesheet.
used
boolean Indicates whether the rule was actually used by some element in the page.

SourceRange

Text range within a resource. All numbers are zero-based.

Type: object

Properties
startLine
integer Start line of range.
startColumn
integer Start column of range (inclusive).
endLine
integer End line of range
endColumn
integer End column of range (exclusive).

ShorthandEntry

Type: object

Properties
name
string Shorthand name.
value
string Shorthand value.
important
boolean Whether the property has "!important" annotation (implies false if absent).

CSSComputedStyleProperty

Type: object

Properties
name
string Computed style property name.
value
string Computed style property value.

CSSStyle

CSS style representation.

Type: object

Properties
styleSheetId
StyleSheetId The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
cssProperties
array [ CSSProperty ] CSS properties in the style.
shorthandEntries
array [ ShorthandEntry ] Computed values for all shorthands found in the style.
cssText
string Style declaration text (if available).
range
SourceRange Style declaration range in the enclosing stylesheet (if available).

CSSProperty

CSS property declaration data.

Type: object

Properties
name
string The property name.
value
string The property value.
important
boolean Whether the property has "!important" annotation (implies false if absent).
implicit
boolean Whether the property is implicit (implies false if absent).
text
string The full property text as specified in the style.
parsedOk
boolean Whether the property is understood by the browser (implies true if absent).
disabled
boolean Whether the property is disabled by the user (present for source-based properties only).
range
SourceRange The entire property range in the enclosing style declaration (if available).

CSSMedia

CSS media rule descriptor.

Type: object

Properties
text
string Media query text.
source
string Source of the media query: "mediaRule" if specified by a @media rule, "importRule" if specified by an @import rule, "linkedSheet" if specified by a "media" attribute in a linked stylesheet's LINK tag, "inlineSheet" if specified by a "media" attribute in an inline stylesheet's STYLE tag. Allowed values: mediaRule, importRule, linkedSheet, inlineSheet.
sourceURL
string URL of the document containing the media query description.
range
SourceRange The associated rule (@media or @import) header range in the enclosing stylesheet (if available).
styleSheetId
StyleSheetId Identifier of the stylesheet containing this object (if exists).
mediaList
array [ MediaQuery ] Array of media queries. Experimental

MediaQuery

Media query descriptor. Experimental

Type: object

Properties
expressions
array [ MediaQueryExpression ] Array of media query expressions.
active
boolean Whether the media query condition is satisfied.

MediaQueryExpression

Media query expression descriptor. Experimental

Type: object

Properties
value
number Media query expression value.
unit
string Media query expression units.
feature
string Media query expression feature.
valueRange
SourceRange The associated range of the value text in the enclosing stylesheet (if available).
computedLength
number Computed length of media query expression (if applicable).

PlatformFontUsage

Information about amount of glyphs that were rendered with given font. Experimental

Type: object

Properties
familyName
string Font's family name reported by platform.
isCustomFont
boolean Indicates if the font was downloaded or resolved locally.
glyphCount
number Amount of glyphs that were rendered with this font.

CSSKeyframesRule

CSS keyframes rule representation.

Type: object

Properties
animationName
Value Animation name.
keyframes
array [ CSSKeyframeRule ] List of keyframes.

CSSKeyframeRule

CSS keyframe rule representation.

Type: object

Properties
styleSheetId
StyleSheetId The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
origin
StyleSheetOrigin Parent stylesheet's origin.
keyText
Value Associated key text.
style
CSSStyle Associated style declaration.

StyleDeclarationEdit

A descriptor of operation to mutate style declaration text.

Type: object

Properties
styleSheetId
StyleSheetId The css style sheet identifier.
range
SourceRange The range of the style text in the enclosing stylesheet.
text
string New style text.

InlineTextBox

Details of post layout rendered text positions. The exact layout should not be regarded as stable and may change between versions. Experimental

Type: object

Properties
boundingBox
DOM.Rect The absolute position bounding box.
startCharacterIndex
integer The starting index in characters, for this post layout textbox substring.
numCharacters
integer The number of characters in this post layout textbox substring.

LayoutTreeNode

Details of an element in the DOM tree with a LayoutObject. Experimental

Type: object

Properties
nodeId
DOM.NodeId The id of the related DOM node matching one from DOM.GetDocument.
boundingBox
DOM.Rect The absolute position bounding box.
layoutText
string Contents of the LayoutText if any
inlineTextNodes
array [ InlineTextBox ] The post layout inline text nodes, if any.
styleIndex
integer Index into the computedStyles array returned by getLayoutTreeAndStyles.

ComputedStyle

A subset of the full ComputedStyle as defined by the request whitelist. Experimental

Type: object

Properties
properties
array [ CSSComputedStyleProperty ]