[{"id":"cssbeg-001","courseId":"css-beginner","domain":"selectors-cascade","topic":"Specificity: ID vs classes","prompt":"A call-to-action link matches both rules below. A teammate expects red because the second selector is longer. What color is the link?","hint":"Specificity is compared column by column, from the left.","source":"https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Cascade/Specificity","interaction":{"type":"single"},"options":[{"id":"a","text":"Red, because four simple selectors outweigh a single one","whyNot":"Specificity is not a total count; three classes and a type never reach the ID column."},{"id":"b","text":"Green, because one ID beats any number of classes and types","why":"The ID rule scores 1-0-0 and the other 0-3-1. Columns are compared left to right, so the higher ID count wins outright."},{"id":"c","text":"Red, because it is declared later in the stylesheet","whyNot":"Source order only breaks ties, and these selectors are not tied."},{"id":"d","text":"Green, but only if the ID rule is in a separate file","whyNot":"Which file a rule lives in does not change its specificity."}],"answer":"b","explanation":"Specificity is written ID-CLASS-TYPE and compared left to right, so a single ID outranks any number of classes and type selectors.","concept":"Specificity is written ID-CLASS-TYPE and compared left to right, so a single ID outranks any number of classes and type selectors.","rev":1,"kind":"scenario","code":"#cta { color: green; }\n\n.page .hero .actions a {\n  color: red;\n}","takeaways":["Specificity is three columns compared left to right, not a sum."]},{"id":"cssbeg-002","courseId":"css-beginner","domain":"selectors-cascade","topic":"Order of appearance","prompt":"base.css is linked before theme.css in the page head. Both contain a rule for .btn with the same selector but a different background. Which background does a .btn get?","hint":"Same origin, same importance, same specificity: what is left to compare?","source":"https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Cascade/Introduction","interaction":{"type":"single"},"options":[{"id":"a","text":"Blue, because the first declaration of a property is kept","whyNot":"The cascade does not favour the first declaration; when everything else ties, the later one wins."},{"id":"b","text":"Whichever file finishes downloading last","whyNot":"Order of appearance follows the document order of the stylesheets, not network timing."},{"id":"c","text":"Orange, because the later declaration wins the tie","why":"Origin, importance and specificity are equal, so the last declaration in order of appearance wins."},{"id":"d","text":"Neither; conflicting rules cancel each other out","whyNot":"Conflicts never cancel; the cascade always picks one winning value."}],"answer":"c","explanation":"When origin, importance, layer and specificity are equal, the declaration that appears last wins.","concept":"When origin, importance, layer and specificity are equal, the declaration that appears last wins.","rev":1,"kind":"scenario","code":"/* base.css */\n.btn { background: blue; }\n\n/* theme.css */\n.btn { background: orange; }","takeaways":["Source order is the cascade's last tie-breaker."]},{"id":"cssbeg-003","courseId":"css-beginner","domain":"selectors-cascade","topic":"Inherited vs non-inherited properties","prompt":"A paragraph is styled with green text and a border. Inside it is an em element with no styles of its own. How does the em render?","hint":"Some properties pass from parent to child by default; others start fresh.","source":"https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Cascade/Inheritance","interaction":{"type":"single"},"options":[{"id":"a","text":"Green text and no border of its own","why":"color is inherited, so the em takes the parent's value; border is not inherited, so it gets the initial value, border-style none."},{"id":"b","text":"Green text with its own border around it","whyNot":"Borders are not inherited; a child would need border: inherit to copy it."},{"id":"c","text":"Default black text with its own border","whyNot":"This flips the rule: color is the inherited one, border is not."},{"id":"d","text":"Default black text and no border","whyNot":"color is an inherited property, so the em does not reset to the default."}],"answer":"a","explanation":"Inherited properties such as color take the parent's computed value when unset; non-inherited ones such as border take their initial value.","concept":"Inherited properties such as color take the parent's computed value when unset; non-inherited ones such as border take their initial value.","rev":1,"kind":"scenario","code":"p {\n  color: green;\n  border: medium solid;\n}","takeaways":["Text properties like color inherit; box properties like border do not."]},{"id":"cssbeg-004","courseId":"css-beginner","domain":"selectors-cascade","topic":"Child vs descendant combinator","prompt":"A nav holds one link directly (Home) and a list whose items hold more links. With the rule nav > a { font-weight: bold; }, which links turn bold?","hint":"The > combinator cares about how many levels sit between the two elements.","source":"https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/Child_combinator","interaction":{"type":"single"},"options":[{"id":"a","text":"All links inside the nav, at any depth","whyNot":"That is what the descendant combinator (a space) does, not >."},{"id":"b","text":"Only the links inside list items","whyNot":"Those links are grandchildren of li's parent, not children of nav."},{"id":"c","text":"None, because the links sit next to a ul","whyNot":"Siblings do not stop a match; the Home link is still a direct child of nav."},{"id":"d","text":"Only Home, the link that is a direct child of nav","why":"The child combinator matches only immediate children, so the nested Blog link is skipped."}],"answer":"d","explanation":"The child combinator (>) matches only direct children, while the descendant combinator (a space) matches at any depth.","concept":"The child combinator (>) matches only direct children, while the descendant combinator (a space) matches at any depth.","rev":1,"kind":"scenario","code":"<nav>\n  <a href=\"/\">Home</a>\n  <ul>\n    <li><a href=\"/blog\">Blog</a></li>\n  </ul>\n</nav>","takeaways":["a > b is one level down; a b is any level down."]},{"id":"cssbeg-005","courseId":"css-beginner","domain":"selectors-cascade","topic":"Pseudo-elements vs pseudo-classes","prompt":"An interviewer asks you to tell pseudo-elements, which style a part of an element, from pseudo-classes, which match a state. Which TWO of these are pseudo-elements?","hint":"Look at the notation the spec uses for parts of an element.","source":"https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/Pseudo-elements","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"::before","why":"It creates a pseudo-element that is the first child of the matched element."},{"id":"b","text":":hover","whyNot":"It is a pseudo-class that matches while the pointer is over the element."},{"id":"c","text":"::first-line","why":"It styles the first line of text of an element, a part rather than a state."},{"id":"d","text":":first-child","whyNot":"It is a pseudo-class that matches an element by its position among siblings."}],"answer":"ac","explanation":"Pseudo-elements use a double colon and style a part of an element; pseudo-classes use a single colon and match a state or position.","concept":"Pseudo-elements use a double colon and style a part of an element; pseudo-classes use a single colon and match a state or position.","rev":1,"kind":"scenario","takeaways":["Double colon for a part (::before), single colon for a state (:hover)."]}]