CssRule Class
https://drafts.csswg.org/cssom/#the-cssrule-interface
public abstract class CssRuleProperties
| Name | Description |
|---|---|
| CssText | https://drafts.csswg.org/cssom/#dom-cssrule-csstext: the getter serializes the rule; the setter does nothing. |
| ParentRule | Gets the rule that contains this rule, or null when the rule is at the top level of a style sheet. |
| ParentStyleSheet | Gets the style sheet that contains the rule, or null when the rule is not in a style sheet. |
| Type | https://drafts.csswg.org/cssom/#dom-cssrule-type: 0 for the rule types that have no legacy type. |
CssText
CSSRules.cshttps://drafts.csswg.org/cssom/#dom-cssrule-csstext: the getter serializes the rule; the setter does nothing.
public string CssText { get; set; }ParentRule
CSSRules.csGets the rule that contains this rule, or null when the rule is at the top level of a style sheet.
public CssRule? ParentRule { get; }ParentStyleSheet
CSSRules.csGets the style sheet that contains the rule, or null when the rule is not in a style sheet.
public CssStyleSheet? ParentStyleSheet { get; }Type
CSSRules.cshttps://drafts.csswg.org/cssom/#dom-cssrule-type: 0 for the rule types that have no legacy type.
public virtual ushort Type { get; }Methods
| Name | Description |
|---|---|
| ToCss(CssFormatter?) | Returns the text of the rule, formatted by formatter (CssFormatter.Default when null, which returns the same text as CssRule.CssText). |
| ToCss(TextWriter, CssFormatter?) | Same as CssRule.ToCss, but writes the text to output instead of building a string. |
ToCss overloads
ToCss(CssFormatter?)
CssRule.Formatting.csReturns the text of the rule, formatted by formatter (CssFormatter.Default when null, which returns the same text as CssRule.CssText).
public string ToCss(CssFormatter? formatter = null)ToCss(TextWriter, CssFormatter?)
CssRule.Formatting.csSame as CssRule.ToCss, but writes the text to output instead of building a string.
public void ToCss(TextWriter output, CssFormatter? formatter = null)Parameters
outputTextWriterformatterCssFormatter?
Constants
| Name | Description |
|---|---|
| CharsetRule | The value of CssRule.Type for @charset rules (CHARSET_RULE). |
| CounterStyleRule | The value of CssRule.Type for @counter-style rules (COUNTER_STYLE_RULE). |
| FontFaceRule | The value of CssRule.Type for @font-face rules (FONT_FACE_RULE). |
| FontFeatureValuesRule | The value of CssRule.Type for @font-feature-values rules (FONT_FEATURE_VALUES_RULE). |
| ImportRule | The value of CssRule.Type for @import rules (IMPORT_RULE). |
| KeyframeRule | The value of CssRule.Type for keyframe rules (KEYFRAME_RULE). |
| KeyframesRule | The value of CssRule.Type for @keyframes rules (KEYFRAMES_RULE). |
| MarginRule | The value of CssRule.Type for page margin rules (MARGIN_RULE). |
| MediaRule | The value of CssRule.Type for @media rules (MEDIA_RULE). |
| NamespaceRule | The value of CssRule.Type for @namespace rules (NAMESPACE_RULE). |
| PageRule | The value of CssRule.Type for @page rules (PAGE_RULE). |
| StyleRule | The value of CssRule.Type for style rules (STYLE_RULE). |
| SupportsRule | The value of CssRule.Type for @supports rules (SUPPORTS_RULE). |
CharsetRule
The value of CssRule.Type for @charset rules (CHARSET_RULE).
public const ushort CharsetRule = 2CounterStyleRule
The value of CssRule.Type for @counter-style rules (COUNTER_STYLE_RULE).
public const ushort CounterStyleRule = 11FontFaceRule
The value of CssRule.Type for @font-face rules (FONT_FACE_RULE).
public const ushort FontFaceRule = 5FontFeatureValuesRule
The value of CssRule.Type for @font-feature-values rules (FONT_FEATURE_VALUES_RULE).
public const ushort FontFeatureValuesRule = 14ImportRule
The value of CssRule.Type for @import rules (IMPORT_RULE).
public const ushort ImportRule = 3KeyframeRule
The value of CssRule.Type for keyframe rules (KEYFRAME_RULE).
public const ushort KeyframeRule = 8KeyframesRule
The value of CssRule.Type for @keyframes rules (KEYFRAMES_RULE).
public const ushort KeyframesRule = 7MarginRule
The value of CssRule.Type for page margin rules (MARGIN_RULE).
public const ushort MarginRule = 9MediaRule
The value of CssRule.Type for @media rules (MEDIA_RULE).
public const ushort MediaRule = 4NamespaceRule
The value of CssRule.Type for @namespace rules (NAMESPACE_RULE).
public const ushort NamespaceRule = 10PageRule
The value of CssRule.Type for @page rules (PAGE_RULE).
public const ushort PageRule = 6StyleRule
The value of CssRule.Type for style rules (STYLE_RULE).
public const ushort StyleRule = 1SupportsRule
The value of CssRule.Type for @supports rules (SUPPORTS_RULE).
public const ushort SupportsRule = 12