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 This is an experimental API that should not be used in production code.
CSSRule.KEYFRAME_RULE 8 CSSKeyframeRule This is an experimental API that should not be used in production code.
Reserved for future use 9 Should be used to define color profiles in the future
CSSRule.NAMESPACE_RULE 10 CSSNamespaceRule This is an experimental API that should not be used in production code.
CSSRule.COUNTER_STYLE_RULE 11 CSSCounterStyleRule This is an experimental API that should not be used in production code.
CSSRule.SUPPORTS_RULE 12 CSSSupportsRule
CSSRule.DOCUMENT_RULE 13 CSSDocumentRule This is an experimental API that should not be used in production code.
CSSRule.FONT_FEATURE_VALUES_RULE 14 CSSFontFeatureValuesRule
CSSRule.VIEWPORT_RULE 15 CSSViewportRule This is an experimental API that should not be used in production code.
CSSRule.REGION_STYLE_RULE 16 CSSRegionStyleRule This is an experimental API that should not be used in production code.
CSSRule.UNKNOWN_RULE 0 CSSUnknownRule This is an obsolete API and is no longer guaranteed to work.
CSSRule.CHARSET_RULE 2 CSSCharsetRule This is an obsolete API and is no longer guaranteed to work. (Removed in most browsers.)

Examples

let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].type);

Specifications

CSS Object Model (CSSOM)
The definition of 'CSSRule.type' in that specification.
Working Draft Obsoleted values CHARSET_RULE and UNKNOWN_RULE. Added value NAMESPACE_RULE. Deprecates CSSRule.type.
Document Object Model (DOM) Level 2 Style Specification
The definition of 'CSSRule.type' in that specification.
Obsolete Initial definition.

Browser compatibility

BCD tables only load in the browser