Quiz Number 6

SWE 432, Fall 2009
October 15


  1. External style sheets are generally preferable to internal style sheets and inline style. Explain why.
    Answer: The whole idea of style sheets is to impose a consistent look and feel to a web site. External style sheets localize style directives in a single location (ie file). Internal style sheets are attached to individual html resources, and so changing them often involves changing multiple files. (Any variant of this is fine.)
  2. Use each of the following 2 style classes (and describe what the effect each is.) ("Use" means give some html that illustrates the effect of the style directive.)
       < STYLE Type = "text/css" >
         p.keypara    {background-color:YELLOW}
          .errorColor {color:RED}
       < /STYLE >
    

    Answer:
    • The first style class states that paragraphs (ie < p> tags of class "keypara") are to have background color of YELLOW.
    • Here is an example of a paragraph of class ".keypara".

    • The second style class states that any tag can use the generic ".errorColor" to highlight the text in that tag RED.
    • Here is an example of a level 2 header in color RED.

    Grading note: HTML syntax isn't the issue; as long as you have a relevant tag and something that indicates you are selecting a style class, that is acceptable.
  3. Describe the pattern matched by each of the following:
    • /^\d{3}-\d{4}$/
    • /quick [A-Za-z]{5} fox/

    Answer:
    • /^\d{3}-\d{4}$/ Matches 3 digits, a dash, and 4 digits, with nothing else on the line.
    • /quick [A-Za-z]{5} fox/ The first and last words ("quick", "fox") match exactly. The middle matches to any 5 character word (upper and/or lower case), such as "brown".