Forum Moderators: not2easy

Message Too Old, No Replies

more than one tag in a style declaration

#navigation ul li p a { what the...?!

         

generic

6:02 am on Mar 5, 2009 (gmt 0)

10+ Year Member



Can someone point me to a good online resource (or even explain for me) what's with css that contains more than one element or tag in the style? ie,...

#navigation ul li p a {
a.menu li {
p.content img {
ul ul li {

...or whatever. Not those ones in particular but the idea behind that. I'm an 'intermediate' CSS writer and I need to find a good description of how this type of thing works because I just don't really get it and that's not good enough for me.

Hope this makes sense and I'm not going crazy :)

lavazza

7:52 am on Mar 5, 2009 (gmt 0)

10+ Year Member



For starters, you could have a look at:

CSS Crash Course - Index
Menu for the WebmasterWorld CSS crash course
[webmasterworld.com]

From personal experience, I'm sure that if/when you have any questions, then simple, straightforward answers will be forthcoming from some of the many helpful regulars here :)

swa66

11:00 am on Mar 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The crash course might not have the answer...

Anyway a selector that goes like
x y {...}

is applied to an html element matching "y" that is a child (no matter how many levels deep) of an html element matching "x"

A space is just one of the options there, others are ">", "+" etc:
they all have their own meaning, but might be less than supported by IE6, so take care if you use those.

Standard: [w3.org...]

generic

6:09 pm on Mar 5, 2009 (gmt 0)

10+ Year Member



Thanks swa66, that's exactly what I thought but I wasn't sure what keywords to use to start googling with. Someone told me something completely different and I wanted to be sure :) Much appreciated!

g1smd

7:40 pm on Mar 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This part of CSS is very powerful.

Say you wanted to style all of the links inside one paragraph.. don't apply a class name to each individual link, that would be a huge amount of code bloat.

Instead, cut down on the amount of code and apply the class name once, to the paragraph. Then style links with

p.class a { ... }
instead.

generic

8:13 pm on Mar 5, 2009 (gmt 0)

10+ Year Member



I've messed around with it in the past and had limited success. I'll definitely have to run some test case to see how I can use/abuse the technique :) Thanks again folks, I always have good luck here!