1D0-61B practice question 1 of 15

Which choice describes a correct order of precedence for implementing CSS?

Full set: 55 questions
Answer options
A: Inline styles override all other styles. Correct answer
B: External styles override all other styles.
C: Internal (embedded) styles override inline styles.
D: External styles override internal (embedded) styles.
Correct Answer:
A. Inline styles override all other styles.
Explanation

The CSS cascade determines which style rule applies when multiple rules conflict. The order of precedence, from lowest to highest, is generally: browser default styles, external style sheets, internal (embedded) style sheets, and finally inline styles. Inline styles are applied directly to an HTML element using the style attribute. Due to their high specificity, they will override any conflicting rules defined in internal or external style sheets. This makes them the most powerful styling method in the cascade, aside from the !important declaration.

Why Incorrect

B. External styles override all other styles. This is incorrect. Both internal (embedded) and inline styles have a higher precedence than external styles in the CSS cascade.
C. Internal (embedded) styles override inline styles. This is incorrect. Inline styles are more specific and therefore have a higher precedence than internal styles.
D. External styles override internal (embedded) styles. This is incorrect. When selectors have equal specificity, the rule that appears last wins. Typically, internal styles are defined after external sheets, giving them precedence.

References

1. World Wide Web Consortium (W3C). CSS Cascading and Inheritance Level 5, Section 6: Cascading. W3C Working Draft, 4 August 2022. This specification details the cascade algorithm, where inline styles are given the highest specificity. It states, "The declarations from a style attribute... are cascaded as if they were inside a style rule with a specificity of (1, 0, 0, 0)". This specificity is higher than any selector in an external or internal sheet can achieve.

Reference: https://www.w3.org/TR/css-cascade-5/#cascading (See Section 6.1. Cascade Sort Criteria and 6.2. Cascading Origins).

2. MDN Web Docs. Cascade and inheritance. Mozilla. This document explains the three main factors of the CSS cascade: importance, specificity, and source order. It explicitly states, "Inline styles... always overwrite any styles in external stylesheets, and thus can be thought of as having the highest specificity."

Reference: https://developer.mozilla.org/en-US/docs/Learn/CSS/Buildingblocks/Cascadeandinheritance (See the "Specificity" section).

3. Massachusetts Institute of Technology (MIT) OpenCourseWare. 6.170 Software Studio, Lecture 3: HTML & CSS. Fall 2005. The lecture slides on CSS rule precedence clearly list the hierarchy from lowest to highest as: Browser default, External style sheet, Internal style sheet, and Inline style.

Reference: https://ocw.mit.edu/courses/6-170-software-studio-spring-2005/resources/lec3/ (See slide 24, "CSS Rule Precedence").

Scroll to Top