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.

Syntax

var type = cssRule.type;

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

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
type
1
12
1
9
≤12.1
1
1
18
4
≤12.1
1
1.0

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CSSRule/type