CSSRule

  • Revision slug: DOM/cssRule
  • Revision title: CSSRule
  • Revision id: 85907
  • Created:
  • Creator: Sevenspade
  • Is current revision? No
  • Comment Heading nesting level; one or more formatting changes

Revision Content

{{ DomRef() }}

An object implementing the CSSRule DOM interface represents a single CSS rule. References to a CSSRule-implementing object may be obtained by looking at a stylesheet's cssRules list.

There are several kinds of rules. The CSSRule interface specifies the properties common to all rules, while properties unique to specific rule types are specified in the more specialized interfaces for those rules' respective types.

Type Rule-specific interface Description
CSSRule.STYLE_RULE {{ Anch("CSSStyleRule") }}  
CSSRule.MEDIA_RULE {{ Anch("CSSMediaRule") }}  
CSSRule.FONT_FACE_RULE {{ Anch("CSSFontFaceRule") }}  
CSSRule.PAGE_RULE {{ Anch("CSSPageRule") }}  Not implemented
CSSRule.IMPORT_RULE {{ Anch("CSSImportRule") }}  
CSSRule.CHARSET_RULE {{ Anch("CSSCharsetRule") }}  
CSSRule.UNKNOWN_RULE {{ Anch("CSSUnknownRule") }}  Not implemented

CSSRule

cssText 
Returns the textual representation of the rule, e.g. "h1,h2 { font-size: 16pt }".
parentRule 
Returns the containing rule, if any (e.g. a style rule inside an @media block).
parentStyleSheet 
Returns the stylesheet object that this rule is part of.
type 
The type of the rule, e.g. CSSRule.CHARSET_RULE or CSSRule.IMPORT_RULE.

CSSStyleRule

selectorText 
Gets/sets the textual representation of the selector for this rule, e.g. "h1,h2".
style 
Returns the CSSStyleDeclaration object for the declaration block of the rule.

CSSMediaRule

CSSFontFaceRule

CSSPageRule

CSSImportRule

CSSCharsetRule

CSSUnknownRule

Specification

See also

{{ languages( { "pl": "pl/DOM/cssRule" } ) }}

Revision Source

<p>{{ DomRef() }}</p>
<p>An object implementing the <code>CSSRule</code> DOM interface represents a single CSS rule. References to a <code>CSSRule</code>-implementing object may be obtained by looking at a <a href="/en/DOM/stylesheet" title="en/DOM/stylesheet">stylesheet</a>'s <code><a href="/en/DOM/stylesheet.cssRules" title="en/DOM/stylesheet.cssRules">cssRules</a></code> list.</p>
<p>There are several kinds of rules. The <code>CSSRule</code> interface specifies the properties common to all rules, while properties unique to specific rule types are specified in the more specialized interfaces for those rules' respective types.</p>
<table class="fullwidth-table"> <tbody> <tr> <th>Type</th> <th>Rule-specific interface</th> <th>Description</th> </tr> <tr> <td><code>CSSRule.STYLE_RULE</code></td> <td>{{ Anch("CSSStyleRule") }}</td> <td> </td> </tr> <tr> <td><code>CSSRule.MEDIA_RULE</code></td> <td>{{ Anch("CSSMediaRule") }}</td> <td> </td> </tr> <tr> <td><code>CSSRule.FONT_FACE_RULE</code></td> <td>{{ Anch("CSSFontFaceRule") }}</td> <td> </td> </tr> <tr> <td><code>CSSRule.PAGE_RULE</code></td> <td>{{ Anch("CSSPageRule") }}</td> <td> Not implemented</td> </tr> <tr> <td><code>CSSRule.IMPORT_RULE</code></td> <td>{{ Anch("CSSImportRule") }}</td> <td> </td> </tr> <tr> <td><code>CSSRule.CHARSET_RULE</code></td> <td>{{ Anch("CSSCharsetRule") }}</td> <td> </td> </tr> <tr> <td><code>CSSRule.UNKNOWN_RULE</code></td> <td>{{ Anch("CSSUnknownRule") }}</td> <td> Not implemented</td> </tr> </tbody>
</table>
<h2 name="CSSRule">CSSRule</h2>
<dl> <dt><a href="/en/DOM/CSSRule/cssText" title="en/DOM/cssRule.cssText">cssText</a> </dt> <dd>Returns the textual representation of the rule, e.g. "h1,h2 { font-size: 16pt }".</dd> <dt><a href="/en/DOM/cssRule.parentRule" title="en/DOM/cssRule.parentRule">parentRule</a> </dt> <dd>Returns the containing rule, if any (e.g. a style rule inside an @media block).</dd> <dt><a href="/en/DOM/CSSRule/parentStyleSheet" title="en/DOM/cssRule.parentStyleSheet">parentStyleSheet</a> </dt> <dd>Returns the <a href="/en/DOM/stylesheet" title="en/DOM/stylesheet">stylesheet</a> object that this rule is part of.</dd> <dt><a href="/en/DOM/cssRule.type" title="en/DOM/cssRule.type">type</a> </dt> <dd>The type of the rule, e.g. <code>CSSRule.CHARSET_RULE</code> or <code>CSSRule.IMPORT_RULE</code>.</dd>
</dl>
<h2 name="CSSStyleRule">CSSStyleRule</h2>
<dl> <dt><a href="/en/DOM/CSSStyleRule/selectorText" title="en/DOM/cssRule.selectorText">selectorText</a> </dt> <dd>Gets/sets the textual representation of the selector for this rule, e.g. "h1,h2".</dd> <dt><a href="/en/DOM/CSSStyleRule/style" title="en/DOM/cssRule.style">style</a> </dt> <dd>Returns the <a href="/en/DOM/CSSStyleDeclaration" title="en/DOM/CSSStyleDeclaration">CSSStyleDeclaration</a> object for the <a class="external" href="http://www.w3.org/TR/1998/REC-CSS2-19980512/syndata.html#block">declaration block</a> of the rule.</dd>
</dl>
<h2 name="CSSStyleRule_2">CSSMediaRule</h2>
<h2 name="CSSFontFaceRule">CSSFontFaceRule</h2>
<h2 name="CSSPageRule">CSSPageRule</h2>
<h2 name="CSSImportRule">CSSImportRule</h2>
<h2 name="CSSCharsetRule">CSSCharsetRule</h2>
<h2 name="CSSUnknownRule">CSSUnknownRule</h2>
<h2 name="Specification">Specification</h2>
<ul> <li><a class="external" href="http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSRule">DOM Level 2 CSS: CSSRule</a></li> <li><a class=" external" href="http://dev.w3.org/csswg/cssom/#css-rules" title="http://dev.w3.org/csswg/cssom/#css-rules">CSS Object Model: CSS Rules</a></li>
</ul>
<h2>See also</h2>
<ul> <li><a href="/en/DOM/Using_dynamic_styling_information" title="en/DOM/Using_dynamic_styling_information">Using dynamic styling information</a></li>
</ul>
<p>{{ languages( { "pl": "pl/DOM/cssRule" } ) }}</p>
Revert to this revision