CssSpecificity

data class CssSpecificity(val a: Int = 0, val b: Int = 0, val c: Int = 0) : Comparable<CssSpecificity> (source)

Represents CSS specificity as defined in the CSS specification.

Specificity is a weight that is applied to CSS rules to determine which rule is applied when multiple rules target the same element.

It is comprised of three components:

  • a: Represents the number of ID selectors in the rule.

  • b: Represents the number of class selectors, attribute selectors, and pseudo-classes in the rule.

  • c: Represents the number of type selectors and pseudo-elements in the rule.

This class provides methods for comparing and adding specificities.

Constructors

Link copied to clipboard
constructor(a: Int = 0, b: Int = 0, c: Int = 0)

Properties

Link copied to clipboard
val a: Int

The number of ID selectors.

Link copied to clipboard
val b: Int

The number of class selectors, attribute selectors, and pseudo-classes.

Link copied to clipboard
val c: Int

The number of type selectors and pseudo-elements.

Functions

Link copied to clipboard
open operator override fun compareTo(other: CssSpecificity): Int
Link copied to clipboard
operator fun get(index: Int): Int
Link copied to clipboard
operator fun plus(other: CssSpecificity): CssSpecificity
Link copied to clipboard
open override fun toString(): String