3. Define a convenience function to add a rule to the style sheet
function addRuleToStyleElement (styleSheetElement, selector, declaration) { styleSheetElement.insertRule (selector + " { " + declaration + " } ", styleSheetElement.cssRules.length); // insert at end of sheet }