"); } else { $mime_type = "text/html"; header("Content-type: $mime_type; charset=utf-8"); } ?> CS-081 Assignment 8 Solutions

CS-081 Assignment 8

Solutions

  1. What is the specificity of html, body?

    Answer: 2 separate selectors, each with a specificity of one (001).

    Select all html and all body elements. (Which is sort of silly to say because there is exactly one of each on every web page. But it’s correct.)

  2. What is the specificity of html > body?

    two (002)

    Select all body elements that are children of html elements. (Again, it’s silly, since every web page has exactly one body element, and it is always a child (one of two children) of the html element.

  3. What is the specificity of .special?

    ten (010)

    Select any elements with a class attribute that has the value “special.”

  4. What is the specificity of p.special?

    eleven (011)

    Select any p elements with a class attribute that has the value “special.”

  5. What is the specificity of a:hover?

    two (002)

    Select all a elements when the mouse hovers over them.

  6. What is the specificity of .off-site a:hover?

    twelve (012)

    Select any a elements that are descendents of any element with a class attribute that has the value “off-site,” when the mouse hovers over them.

  7. What is the specificity of #footer?

    one hundred (100)

    Select the element that has an id attribute with the value “footer,” if there is one.

  8. What is the specificity of #footer a?

    one hundred one

    Select any a elements, if there are any, that are descendents of the element with an id that has the value, “footer,” if there is one.

  9. What is the specificity of #footer a:hover?

    one hundred two (102)

    If there is an element with an id that has the value “footer,” select all descendent a elements (if there are any) when the mouse hovers over them.

  10. What is the specificity of p:first-child?

    two (002)

    Select any p elements that are the first child of another element.

  11. What is the specificity of div > p.interesting span:hover img[src$=jpg]?

    twenty-five (025)

    As stated in the assignment web page, it’s simply, “all img elements, if there are any, that have a src attribute value ending in “jpg” and which are descendents of a span that the mouse is hovering over, provided the span is a descendent of a p element that has the class “interesting”, provided the p is a child of a div.”