Prev: Sprites for screen readers
Next: Center Table using CSS
From: Stan Brown on 14 Feb 2010 10:05 13 Feb 2010 15:28:16 GMT from Camille Petersen <cpet_magnus(a)hotmail.com>: > > When I inspect a CSS I found entries of the kind > > TABLE TD { .... } It means TD within TABLE, as opposed to TD not within TABLE. It does not (as you observe) mean TD or TABLE. "TD not within TABLE" is rather silly, but the above rule is a bit more specific than just a plain TD rule. (Specificity is rather technical, and as a beginner you should not worry too much about it.) A better example is DIV P { ... } which styles a P differently when it is within a DIV. > Furthermore I would like to setup a margin before (=to the > top/north) of a TABLE. Can I simply write > > margintop: 20px; No, for three reasons: 1. You must put it within braces and after a selector. 2. The property is margin-top, not margintop. 3. Though CSS allows it, you should never specify text sizes or margin sizes in pixels Use em, or in certain situations %. table {margin-top:0.75em;} -- Stan Brown, Oak Road Systems, Tompkins County, New York, USA http://OakRoadSystems.com/ HTML 4.01 spec: http://www.w3.org/TR/html401/ validator: http://validator.w3.org/ CSS 2.1 spec: http://www.w3.org/TR/CSS21/ validator: http://jigsaw.w3.org/css-validator/ Why We Won't Help You: http://diveintomark.org/archives/2003/05/05/why_we_wont_help_you
From: Stan Brown on 15 Feb 2010 11:07 Mon, 15 Feb 2010 07:51:04 +1100 from dorayme <doraymeRidThis(a)optusnet.com.au>: > > In article <MPG.25e1db53d00b935698bf92(a)news.individual.net>, > Stan Brown <the_stan_brown(a)fastmail.fm> wrote: > > > (Specificity is rather > > technical, and as a beginner you should not worry too much about it.) Note: I didn't say to ignore it entirely, just not to worry too much about it. > Perhaps *some* basics on this are important for anyone writing > CSS to understand. There are many articles on this. > > At least look at > > <http://htmldog.com/guides/cssadvanced/specificity/> From which the very first line is "It may not seem like something that important, and in most cases you won't come across any conflicts at all," It may be a limitation of my imagination, but can you give a realistic scenario, for a beginner, where it matters whether you write TABLE TD or just plain TD as a selector? I can't think of one. -- Stan Brown, Oak Road Systems, Tompkins County, New York, USA http://OakRoadSystems.com/ HTML 4.01 spec: http://www.w3.org/TR/html401/ validator: http://validator.w3.org/ CSS 2.1 spec: http://www.w3.org/TR/CSS21/ validator: http://jigsaw.w3.org/css-validator/ Why We Won't Help You: http://diveintomark.org/archives/2003/05/05/why_we_wont_help_you
From: Jukka K. Korpela on 15 Feb 2010 13:18 Stan Brown wrote: > It may be a limitation of my imagination, but can you give a > realistic scenario, for a beginner, where it matters whether you > write TABLE TD or just plain TD as a selector? I can't think of one. The question was not posed to me, but... If you're authoring pages in an environment that you control, it probably doesn't matter. But if you must play in an environment where other people's CSS code participates in the rendering, it matters a lot. A very simple example: Suppose you work with pages managed in a Content Messing OOOPS Management System (CMS), where a system-wide CSS file might say td { font: 10px Arial; } Suppose you have the luxury of feeding in your own CSS as well, via something that gets inserted into a page before a reference to the system-wide CSS file. Now, if you say, in that CSS code of yours, td { font: 100% Calibri, Arial, sans-serif; } it gets ignored in the cascade, since other things being equal, the latter rule wins, and the system-wide CSS comes as latter. Instead, if you say table td { font: 100% Calibri, Arial, sans-serif; } then other things aren't equal: your rule has higher specificity, so it wins. -- Yucca, http://www.cs.tut.fi/~jkorpela/
From: dorayme on 15 Feb 2010 17:19 In article <MPG.25e33b6f45695df098bfa6(a)news.individual.net>, Stan Brown <the_stan_brown(a)fastmail.fm> wrote: > Mon, 15 Feb 2010 07:51:04 +1100 from dorayme > <doraymeRidThis(a)optusnet.com.au>: > > > > In article <MPG.25e1db53d00b935698bf92(a)news.individual.net>, > > Stan Brown <the_stan_brown(a)fastmail.fm> wrote: > > > > > (Specificity is rather > > > technical, and as a beginner you should not worry too much about it.) > > Note: I didn't say to ignore it entirely, just not to worry too much > about it. > OK, noted. With respect though, no one should worry about anything too much. > > Perhaps *some* basics on this are important for anyone writing > > CSS to understand. There are many articles on this. > > > > At least look at > > > > <http://htmldog.com/guides/cssadvanced/specificity/> > > From which the very first line is > "It may not seem like something that important, and in most cases you > won't come across any conflicts at all," > And it continues: "but the larger and more complex your CSS files become, or the more CSS files you start to juggle with, the greater likelihood there is of conflicts turning up" Short and sweet CSS is more the product of practised skill. Beginners are known to ramble on in the most over complicated way in their sheets. Many of even the more experienced of us do this as we develop and before we take the cleaning brush to our effort. It is actually quite important to know some basics about about specificity. > It may be a limitation of my imagination, but can you give a > realistic scenario, for a beginner, where it matters whether you > write TABLE TD or just plain TD as a selector? I can't think of one. She might be wanting to add a rule to override just the TD one but find it convenient to have the override at the top of the sheet rather than at the bottom for various reasons (like not being able to find the thing that is to be overridden! Specificity can nail stuff under time pressure). The override, by the same sort of reasoning, might more conveniently be referenced (as a link) in a different sheet altogether. This latter might for various reasons be before (in the head) the one in which the simpler less specific TD rule is. In other words, it is handy to be able to take advantage of specificity rather than queue order. And it is more than handy, for diagnostic purposes, to be able to spot what is going on. -- dorayme
From: Stan Brown on 15 Feb 2010 18:22 Mon, 15 Feb 2010 11:07:59 -0500 from Stan Brown <the_stan_brown(a)fastmail.fm>: > It may be a limitation of my imagination, but can you give a > realistic scenario, for a beginner, where it matters whether you > write TABLE TD or just plain TD as a selector? I can't think of one. Jukka and Dorayme gave good examples: user style sheet overriding author style through specificity, and in a single style sheet using specificity so that the order doesn't matter. I won't quibble about whether those are *beginner* techniques, because I think I can use them myself. :-) -- Stan Brown, Oak Road Systems, Tompkins County, New York, USA http://OakRoadSystems.com/ HTML 4.01 spec: http://www.w3.org/TR/html401/ validator: http://validator.w3.org/ CSS 2.1 spec: http://www.w3.org/TR/CSS21/ validator: http://jigsaw.w3.org/css-validator/ Why We Won't Help You: http://diveintomark.org/archives/2003/05/05/why_we_wont_help_you
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Sprites for screen readers Next: Center Table using CSS |