CSSRule.type
Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
The read-only type
property of the
CSSRule
interface is a deprecated property that returns an integer
indicating which type of rule the CSSRule
represents.
Value
An integer which will be one of the type constants listed in the table below.
Type | Value | Rule-specific interface | Comments and examples |
---|---|---|---|
CSSRule.STYLE_RULE |
1 |
CSSStyleRule |
The most common kind of rule:selector { prop1: val1; prop2: val2; } |
CSSRule.IMPORT_RULE |
3 |
CSSImportRule |
An @import rule. (Until the documentation is
completed, see the interface definition in the Mozilla source code:
nsIDOMCSSImportRule.)
|
CSSRule.MEDIA_RULE |
4 |
CSSMediaRule |
|
CSSRule.FONT_FACE_RULE |
5 |
CSSFontFaceRule |
|
CSSRule.PAGE_RULE |
6 |
CSSPageRule |
|
CSSRule.KEYFRAMES_RULE |
7 |
CSSKeyframesRule
|
|
CSSRule.KEYFRAME_RULE |
8 |
CSSKeyframeRule
|
|
Reserved for future use | 9 |
Should be used to define color profiles in the future | |
CSSRule.NAMESPACE_RULE |
10 |
CSSNamespaceRule
|
|
CSSRule.COUNTER_STYLE_RULE |
11 |
CSSCounterStyleRule
|
|
CSSRule.SUPPORTS_RULE |
12 |
CSSSupportsRule |
|
CSSRule.DOCUMENT_RULE |
13 |
CSSDocumentRule
|
|
CSSRule.FONT_FEATURE_VALUES_RULE |
14 |
CSSFontFeatureValuesRule |
|
CSSRule.VIEWPORT_RULE |
15 |
CSSViewportRule
|
|
CSSRule.REGION_STYLE_RULE |
16 |
CSSRegionStyleRule
|
|
CSSRule.UNKNOWN_RULE |
0 |
CSSUnknownRule |
|
CSSRule.CHARSET_RULE |
2 |
CSSCharsetRule |
(Removed in most browsers.) |
Examples
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].type);
Specifications
Specification |
---|
CSS Object Model (CSSOM) # concept-css-rule-type |
Browser compatibility
BCD tables only load in the browser