Taming CSS Selectors

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    11 Favorites

    Taming CSS Selectors - Presentation Transcript

    1. TAMING SELECTORS sanity for our stylesheets
    2. SIZE OF THE CSS FILE AND IMPLIED HTTP REQUESTS are the biggest factor for CSS performance
    3. REFLOWS AND RENDERING TIME are (much!) less important
    4. DUPLICATION IS WORSE THAN STALE RULES because we have tools to deal with the later
    5. DEFINE DEFAULT VALUES Don’t repeat this code in every object
    6. #weatherModule h3{color:red;} #tabs h3{color:blue} DEFINE DEFAULT VALUES Don’t repeat this code in every object
    7. X #weatherModule h3{color:red;} #tabs h3{color:blue} DEFINE DEFAULT VALUES Don’t repeat this code in every object
    8. X #weatherModule h3{color:red;} #tabs h3{color:blue} DEFINE DEFAULT VALUES Don’t repeat this code in every object h1, .h1{...} h2, .h2{...} h3, .h3{...} h4, .h4{...} h5, .h5{...} h6, .h6{...}
    9. DEFINE STRUCTURE IN A SEPARATE CLASS Don’t repeat this code in every object block inner hd bd ft
    10. div.error{...} STYLE CLASSES rather than elements
    11. X div.error{...} STYLE CLASSES rather than elements .error{ most of the code goes here }
    12. X div.error{...} STYLE CLASSES rather than elements .error{ most of the code goes here } div.error{ } p.error{ exceptions only } em.error{ }
    13. div{...} ul{...} p{..} AVOID STYLING ELEMENTS unless defining defaults
    14. div{...} X ul{...} p{..} AVOID STYLING ELEMENTS unless defining defaults .error{...} .section{...} .products{...}
    15. .myModule .inner b{...} .myModule2 b {...} GIVE RULES THE SAME STRENGTH Use cascade order to overwrite previous rules
    16. X .myModule .inner b{...} .myModule2 b {...} GIVE RULES THE SAME STRENGTH Use cascade order to overwrite previous rules .myModule b{...} .myModule2 b {...}
    17. .sidebar ul{...} .header ul {...} AVOID SPECIFYING LOCATION Apply classes to the object you wish to change
    18. X .sidebar ul{...} .header ul {...} AVOID SPECIFYING LOCATION Apply classes to the object you wish to change .mainNav{...} .subNav {...}
    19. AVOID OVERLY SPECIFIC CLASSES they’re all semantic, but limiting
    20. AVOID OVERLY SPECIFIC CLASSES they’re all semantic, but limiting .vehicle{...} .motorcycle{...} .ducati{...} .ducatiMonster620{...} .nicolesDucatiMonster620{...}
    21. AVOID OVERLY SPECIFIC CLASSES they’re all semantic, but limiting .vehicle{...} .motorcycle{...} .ducati{...} X .ducatiMonster620{...} .nicolesDucatiMonster620{...}
    22. #myUniqueIdentifier{...} #myUniqueIdentifier2{...} AVOID SINGLETONS ids can only be used once in any given page Source: Chris Griego
    23. X #myUniqueIdentifier{...} #myUniqueIdentifier2{...} AVOID SINGLETONS ids can only be used once in any given page Source: Chris Griego
    24. Media Subheading Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. USE MIXINS to avoid repeating code Media Extended Subheading Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    25. .inner{...} .weatherMod .inner{...} .tr{...} .weatherMod .tr{...} .bl{...} .weatherMod .bl{...} ENCAPSULATION don’t access sub-nodes of an object directly inner
    26. .inner{...} X .weatherMod .inner{...} .tr{...} .weatherMod .tr{...} .bl{...} .weatherMod .bl{...} ENCAPSULATION don’t access sub-nodes of an object directly inner

    + Nicole SullivanNicole Sullivan, 4 months ago

    custom

    1195 views, 11 favs, 2 embeds more stats

    From Nicole's presentation at the CSS Summit. This more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1195
      • 1176 on SlideShare
      • 19 from embeds
    • Comments 0
    • Favorites 11
    • Downloads 44
    Most viewed embeds
    • 18 views on http://adamlu.com
    • 1 views on https://www.galileo.edu

    more

    All embeds
    • 18 views on http://adamlu.com
    • 1 views on https://www.galileo.edu

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories