Knowledge check: CSS selectors

Knowledge check: CSS selectors

  1. While specifying the ideal logical order of the four link-states added as rules in CSS code, what pseudo-class will you add second?

    • Hover

    • Active

    • Link

    • Visited

  2. For a given <div> tag and <p> tag, which of the following will be the correct syntax for use of adjacent sibling combinator?

    • div > p

    • div + p

    • div ~ p

    • div p

  3. Calculate the specificity of the following selector:

     ul#alpha li.visited
    
    • 22

    • 13

    • 103

    • 112

  4. nth-last-of-type is a pseudo element that matches the last sibling from a list of siblings of specific type inside a parent.

    • TRUE

    • FALSE

  5. For the given HTML code, irrespective of the effect on other list elements, which of the following will be a valid selector to ensure “Little” is coloured “red”? Select all that apply.

     <body>
        <ul>
           <li class="red">Little</li>
           <li>Lemon</li>
           <li>Restaurant</li>
        </ul>
     </body>
    
    • .red{ color: red; }

    • li { color: red; }

    • li > red { color: red; }

    • #red { color: red; }

    • ul > .red{ color: red; }

  6. Which of the selectors below will select <div> tags with a title attribute in CSS?

    • div.title

    • #title

    • div#title

    • div[title]