Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

CSS Declaration Block

ACSS declaration block is an ordered collection of CSS properties and values. It is represented in the DOM as aCSSStyleDeclaration.

Each property and value pairing is known as aCSS declaration. The CSS declaration block has the following associated properties:

computed flag

Set if theCSSStyleDeclaration object is a computed rather than specified style. Unset by default.

declarations

TheCSS declarations associated with this object.

parent CSS rule

TheCSSRule that the CSS declaration block is associated with, otherwise null.

owner node

Theelement that the CSS declaration block is associated with, otherwise null.

updating flag

Set when the CSS declaration block is updating the owner node'sstyle attribute.

When aCSSStyleDeclaration is returned by aCSS Object Model (CSSOM) interface these properties are set to appropriate values as defined by the specification.

Basic example

The following example shows a CSS rule with a declaration block for theh1 element. The CSS declaration block is the lines between the curly braces.

css
h1 {  margin: 0 auto;  font-family: "Helvetica Neue", "Arial", sans-serif;  font-style: italic;  color: rebeccapurple;}

We can return aCSSStyleDeclaration representing this CSS declaration block usingCSSStyleRule.style.

js
let myRules = document.styleSheets[0].cssRules;let rule = myRules[0]; // a CSSStyleRuleconsole.log(rule.style); // a CSSStyleDeclaration object

Specifications

Specification
CSS Object Model (CSSOM)
# css-declaration-blocks

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp