TK Study

Multiple choice › CSS

CSS

1. CSS

An HTML element has id="intro" and class="note". The CSS has p {color:red;} .note {color:blue;} #intro {color:green;}. What colour is the text?

  1. Red
  2. Green
  3. Black
  4. Blue
Answer

B

Specificity: id selectors beat class selectors, which beat element selectors. So #intro wins.

2. CSS

What is the main advantage of using one external CSS file for a whole website?

  1. It encrypts the pages
  2. The pages no longer need HTML
  3. Consistent appearance and easy maintenance because a change is made in one place
  4. The website loads without a server
Answer

C

External CSS separates presentation from content, giving consistency across pages and one place to update.

3. CSS

Which CSS selector targets all elements with class="warning"?

  1. warning
  2. *warning
  3. .warning
  4. #warning
Answer

C

. selects classes, # selects ids, and a bare name selects an element type (tag). Sample exam Q16 tested id v class.