You are not logged in.

#1 2005-05-16 18:36:27

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

css usage... questions

ok, I'm not visually inclined... I have some css questions.. about stuff I don't understand.

Why is it better to do:

tr.headingRow {...}

than:

.headingRow {...}

yeah I understand that there's implied usage in the first example... but really, it's not going to cause issues...

Number two... why do people insist on stuff like this:

tr.headingRow td img.customImg { ... }

over:

img.customImg { ... }

Now, I can understand the nesting, only use the customImg inside the headingRow and a td... but, come on people... that's just so restrictive to me... what if you move that td out to a div? you now have to change your stylesheet as well... but with example #2 nothing changes...

some of the stuff I see is rediculous...

td.blah { color: white; }
div.abracadabra { color: white; }
span.customSpan {color: white; }
... etc ...

and this could all be replaced with:

.white { color: white; }

and you save a mess of lines...

so, wtf... can someone explain this to me... who deemed this "proper" usage?

Offline

#2 2005-05-16 19:08:37

i3839
Member
Registered: 2004-02-04
Posts: 1,185

Re: css usage... questions

You should use it only when needed of course, if plain .something {} works then it's just stupid.

As far as I know it's mainly used to override an existing rule. e.g. a global td rule to markup all td's in one sweep, and then specific .something rd {} rules to single certain exceptions out.

I've had once a css-only dropdown menu implementation (thus avoiding JS), and there the more obscure things are really needed, but IE didn't eat it.

Offline

#3 2005-05-16 19:11:20

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,615
Website

Re: css usage... questions

No idea. I generally make my scopes large as well.
I mean, it is not like I run out of names for things, it is not like I am trying to encapsulate things in an OO paradigm (no data hiding possible in css), and I generall prefer simplicity to excessive verbosity.

I only use the nesting to classify elements that I don't name.
'tbody div' for example. But never for named objects. That is just silly to me.

heh. Silly phrakture. Inducing me to rant. roll


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#4 2005-05-16 19:34:58

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: css usage... questions

see that's what I was thinking - only use nesting when non-id'd - but then you see stupid stuff like:

table tr td { ... }

...sigh....
I think the problem I have wrapping my head around what people do sometimes is that I forget "web designer != developer" and these people don't think like someone who knows how to code...

i generally have a whole mess of .someRule rules, and rarely classify them by element type

Offline

#5 2005-05-16 20:20:40

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,615
Website

Re: css usage... questions

yeah. occasionally I will do something equally stupid like..
#foo div {}

lol.
*shakes head and goes back to his corner*


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#6 2005-05-29 15:05:37

FUBAR
Member
From: Belgium
Registered: 2004-12-08
Posts: 1,029
Website

Re: css usage... questions

I never even heard of

.something {}

I guess they skipped that option in the webdesign course at my school.


A bus station is where a bus stops.
A train station is where a train stops.
On my desk I have a workstation.

Offline

#7 2005-05-29 15:52:24

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: css usage... questions

the "." names apply to <tag class="something" />
"." is for the class attribute

Offline

#8 2005-05-30 10:17:09

lanrat
Member
From: Poland
Registered: 2003-10-28
Posts: 1,274

Re: css usage... questions

I can only imagine this could be useful with very very complex webpages as a kind of optimisation (?). But this would also introduce so much complexity with scripting that It could only make programming more difficult IMO.

I'm mostly using .something {} syntax and it's clear and optimised enough for me.

Offline

#9 2005-05-30 16:04:47

FUBAR
Member
From: Belgium
Registered: 2004-12-08
Posts: 1,029
Website

Re: css usage... questions

phrakture wrote:

the "." names apply to <tag class="something" />
"." is for the class attribute

Ooh OK. So

.fancymenu { }

would work for

<p class="fancymenu">blah</p>
<div class="fancymenu">blah</div>
<ul class="fancymenu">blah</ul>
...

That's actually pretty cool. big_smile


A bus station is where a bus stops.
A train station is where a train stops.
On my desk I have a workstation.

Offline

#10 2005-05-30 17:15:06

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: css usage... questions

yeah, the .something {} is what I use 90% of the time, because I don't need to worry about what element I'm styling...

Offline

Board footer

Powered by FluxBB