The cascade Flashcards
What is the cascade ?
The cascade is the algorithm for solving conflicts where multiple CSS rules apply to an HTML element.
What are the 4 stages of the cascade algorithm ?
Position and order of appearance: the order of which your CSS rules appear
Specificity: an algorithm which determines which CSS selector has the strongest match
Origin: the order of when CSS appears and where it comes from, whether that is a browser style, CSS from a browser extension, or your authored CSS
Importance: some CSS rules are weighted more heavily than others, especially with the !important rule type
What is the order of specificity of CSS origins from less specific to more specific ?
- User agent base styles. These are the styles that your browser applies to HTML elements by default.
- Local user styles. These can come from the operating system level, such as a base font size, or a preference of reduced motion. They can also come from browser extensions, such as a browser extension that allows a user to write their own custom CSS for a webpage.
- Authored CSS. The CSS that you author.
- Authored !important. Any !important that you add to your authored declarations.
- Local user styles !important. Any !important that come from the operating system level, or browser extension level CSS.
- User agent !important. Any !important that are defined in the default CSS, provided by the browser.
What is the CSS specificity ?
It is an algorithm which determines which CSS selector has the strongest match
Which rule can have priority over an inlinestyleattribute ?
a declaration that has!importantdefined.
Which of a class and an element has the highest specificity ?
The class
What is the order of “importance” of css rules from least important, to most important ?
normal rule type, such asfont-size,backgroundorcolor
animationrule type
!importantrule type (following the same order as origin)
transitionrule type
What is the universal selector number of points ?
0 point
What is the number of point of an element or a pseudo-element selector ?
1 point
What is the number of point of class, pseudo-class and atrribute selectors ?
10 points
How many point does Tlthe:not()pseudo-class itself adds to the specificity calculation ?
Nothing. 0 points.
However, the selectors passed in as arguments do get added to the specificity calculation.
What is the number of points of an ID selector?
100 points
What is the number of points of an inline style attribute ?
CSS applied directly to thestyleattribute of the HTML element, gets aspecificity score of 1,000 points.
What is the number of points of an !importantrule attribute ?
10,000 points. This is the highest specificity that one individual item can get.