Css Specificity

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.

5 comments

Comments 1 - 5 of 5 previous next Post a comment

  • + manugoel2003 manugoel2003 9 months ago
    Well the camp went fantastic... it was wonderful meeting u guys and talking to u.... I got to know how aware students are these days.... I am not even half aware after 4 yr industry experience :) .... loved ur campus.... and wud definitely love to come again.... that is if u ppl wud like to hear me speak on the same boring topics
  • + graphicmist Manish Kutaula 9 months ago
    It all depends upon the sponsorship for the event.
    What do you think about OSScamp @ nainital.
  • + manugoel2003 manugoel2003 9 months ago
    thanx man!!!.... I hoped to deliver this talk at the camp.... but most of u were not aware of CSS much.... so, maybe next time (if u sponsor my visit :D)
  • + graphicmist Manish Kutaula 9 months ago
    good one.. my basics are still week.
  • + anish008 anish008 2 years ago
    good one manu... keep it up
Post a comment
Embed Video
Edit your comment Cancel

6 Favorites

Css Specificity - Presentation Transcript

  1. CSS Specificity By Manu Goel
  2. Contents
    • CSS Specificity
    • Exercise 1
    • Answer
    • General Priority
    • Specificity Hierarchy
    • Calculating Specificity
    • Excercise 1 (Revisited)
  3. Contents
    • The Trump Card
    • Conclusion
    • References & Worthy Readings
    • Thank You
  4. CSS Specificity
    • Specificity determines, which CSS rule is applied by the browsers
  5. Excercise 1
    • Anchor with class “spl” will be green or red?
    • <style>
    • ul#blogroll a { color: red; }
    • a.spl { color: green; }
    • </style>
    • <ul id=&quot;blogroll&quot;>
    • <li><a href=&quot;b1.html&quot;>Blog 1</a></li>
    • <li><a href=&quot;b2.html&quot;>Blog 2</a></li>
    • <li><a href=&quot;b3.html&quot; class=&quot;spl&quot;>Blog 3</a></li>
    • <li><a href=&quot;b4.html&quot;>Blog 4</a></li>
    • </ul>
  6. Answer
    • RED
  7. General Priority
    • User Stylesheet
    • Author Stylesheet
      • Inline CSS declaration using STYLE attribute
      • Internal CSS, inside STYLE tags
      • External CSS file
  8. Specificity Hierarchy pre, :before, :after, :first-line, etc .class, [attribute], :active, :focus, etc #whatever style=“color: blue;” color: blue !important; Example 1 Elements, pseudo-elements 10 Classes, attributes, pseudo-classes 100 IDs 1000 Inline styles n/a (Highest) !important Specificity Category
  9. Calculating Specificity element selector (1) Sith power (specificity): 0, 0, 1 class selector (10) Sith power (specificity): 0, 1, 0 id selector (100) Sith power (specificity): 1, 0, 0
  10.  
  11. Excercise 1 (Revisited)
    • <style>
    • ul#blogroll a { color: red; } Specificity : 1,0,2
    • a.spl { color: green; } Specificity : 0,1,1
    • </style>
    • <ul id=&quot;blogroll&quot;>
    • <li><a href=&quot;b1.html&quot;>Blog 1</a></li>
    • <li><a href=&quot;b2.html&quot;>Blog 2</a></li>
    • <li><a href=&quot;b3.html&quot; class=&quot;spl&quot;>Blog 3</a></li>
    • <li><a href=&quot;b4.html&quot;>Blog 4</a></li>
    • </ul>
  12. The Trump Card
    • !important is not the solution to specificity woes
    • This shortcut can lead to really messed up CSS in big projects
  13. Conclusion
    • Minimize use of !important [ Understanding Specificity , Selector Specificity ]
    • Use id to make a rule more specific
    • Minimize the number of selectors [ Understanding Specificity ]
  14. Conclusion
    • Use the least specific selector combination required to style an element
    • Use LVHA for link styling link-visited-hover-active [ Link Specificity ]
    • If in confusion use [ CSS specificity calculator ]
  15. References & Worthy Readings
    • http://www.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/
    • http://www.stuffandnonsense.co.uk/archives/css_specificity_wars.html
    • http://www.molly.com/2005/10/06/css2-and-css21-specificity-clarified/
    • http://juicystudio.com/article/selector-specificity.php
    • http://www.htmldog.com/guides/cssadvanced/specificity/
    • http://meyerweb.com/eric/css/link-specificity.html
    • http://www.w3.org/TR/REC-CSS2/cascade.html#specificity
    • http://monc.se/kitchen/38/cascading-order-and-inheritance-in-css
    • http://iamacamera.org/default.aspx?id=95
    • http://www.rebelinblue.com/specificity.php
    • http://www.brunildo.org/test/IEASpec.html
    • Thank You

+ manugoel2003manugoel2003, 2 years ago

custom

1676 views, 6 favs, 1 embeds more stats

A presentation with a brief overview about CSS Spec more

More info about this document

© All Rights Reserved

Go to text version

  • Total Views 1676
    • 1668 on SlideShare
    • 8 from embeds
  • Comments 5
  • Favorites 6
  • Downloads 59
Most viewed embeds
  • 8 views on http://www.slideshare.net

more

All embeds
  • 8 views on http://www.slideshare.net

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