• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Designing for the Real World

JavaScript and Style Sheets

JavaScript goes hand-in-hand with Cascading Style Sheets. It can be used to access and act on any CSS attribute. There's a slight difference in the way the names of the attributes are handled in JavaScript, though. Fortunately, the conversion is simple and follows a strict rule.

Where property names in CSS are always in lowercase and the words are separated by hyphens, you drop the hyphens in JavaScript and capitalize the beginning of every word except the first one. For example, the CSS attribute font-family would be fontFamily in JavaScript. Three-word attributes are done the same way; the CSS attribute page-break-after would be pageBreakAfter in JavaScript.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint