css element within element....

W

WindAndWaves

Hi Gurus

This question relates to stylesheets.

Is it possible to say to define the behaviour of classes, elements, etc... within other elements

For example of the A-elements within the <DIV CLASS="content">, if so, how do i do that?

Sorry I am really new to this kind of thing and I do not have a computer background.

I have seen stuff around like A > .content {....} is that the kind of thing I should be using? If so, what should I watch for?

Cheers


- Nicolaas
 
S

Steve Pugh

WindAndWaves said:
This question relates to stylesheets.

Is it possible to say to define the behaviour of classes, elements, etc... within other elements
Yes.

For example of the A-elements within the <DIV CLASS="content">, if so, how do i do that?

div.content a {foo:bar;}
Sorry I am really new to this kind of thing and I do not have a computer background.

The word you are looking for is "selector". A selector in CSS is the
part of a style rule that specifies which elements the properties
deined the in rule apply to. CSS includes a large number of different
selectors that can be combined in many possiblle ways.

The simplest selector is an element selector
div {}
which selects all elements of that type.
A class selector
..foo {}
selects all elements with that class. These can be combined to select
all elements of a given type with that class.
div.foo {}

You're asking about the descendent selector that selects all elements
that descendents of another element. The descendent selector is just a
space.

div p {}
selects all p elements that are descendets of divs.
div.foo p b.bar {}
selects all b elements with a class of bar that are descendents of p
elements that are themselves descendents of div elements with a class
of foo.

See http://www.w3.org/TR/CSS21/selector.html

But be aware that some browsers (stand up IE) don't support a lot of
the selectors.
http://www.blooberry.com/indexdot/css/syntax/selectors/selectors.htm
isn't fully complete or up to date but does tell you what IE6 does and
doesn't support which is the most important thing to know today.
I have seen stuff around like A > .content {....} is that the kind of thing I should be using?

That's a child selector. It works like a descendent selector but only
applies to immediate children.
<div class="foo">
<p></p>
<div>
<p><p>
</div>
<p></p>
</div>

..foo > p {}
applies to the first and third paragraphs because they are children of
the element with class foo but not to the second because it is a
grandchild.
If so, what should I watch for?

IE doesn't support child selectors. If you write it with spaces then
IE will treat it as a descendent selector. If you write it without
spaces then IE will ignore it.
..foo > p is treated as .foo p
..foo>p is ignored altogether.

Steve
 
B

Barbara de Zoete

This question relates to stylesheets.

Then why do you come to alt.html?
I've added ciwas, and f'up set hence.
Is it possible to say to define the behaviour of classes, elements, etc...
within other elements

For example of the A-elements within the <DIV CLASS="content">, if so, how do
i do that?

Sorry I am really new to this kind of thing and I do not have a computer
background.

That's okay. We've all started with CSS at some time in our lives. But, if
you're that new with this, perhaps you should start with on-line tutorials to
get some idea of how CSS works:

<http://www.w3.org/MarkUp/Guide/Style.html> for example.

There is much more. Google for it.

As a rule of thumb:
- Start styling the elements that you use in the markup of your pages, for
example <p>, <h#>, <div> and get some experience with that, get a feel for what
CSS is and does;
- When comfortable with styling the single elements, experiment some with
creating (containing) divisions and setting specific styles for those and the
elements inside them, but then you are already somewhat advanced.

Also, lurk in some of the ciwa* groups, especially ciwas. You can learn a great
deal from that. Last, look at the style sheets of sites you visit and like. Try
to understand what you see (combined with the markup).

Play around with (correct) markup and css and when you've created something in
your personal sandbox, there is no harm in comming back here (meaning ciwas) and
ask for help with specific problems. Don't forget to validate code (both markup
and styles) before you ask for help.

<http://validator.w3.org/> for markup and
<http://jigsaw.w3.org/css-validator/> for css

--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'
 
E

Els

WindAndWaves said:
Hi Gurus

This question relates to stylesheets.

Is it possible to say to define the behaviour of classes,
elements, etc... within other elements

Yes :)
For example of the A-elements within the <DIV
CLASS="content">, if so, how do i do that?

div.content a{styles...}
Sorry I am really new to this kind of thing and I do not
have a computer background.

Handy tool for you:
http://gallery.theopalgroup.com/selectoracle/
I have seen stuff around like A > .content {....} is that
the kind of thing I should be using? If so, what should I
watch for?

No, that's just a hack to get different browsers to do
different things.
 
B

Barbara de Zoete

No, that's just a hack to get different browsers to do
different things.

Come again? Using the '>' in a style selector means the author wants all direct
decendents, also know as 'children' to render with a specific style. Thus the
'>' in a selector creates a child selector.
It is only if the spaces are left out, 'foo>bar' instead of 'foo > bar' (that
gets mis-interpreted by IE), that the styles for the selector are ignored by a
certain obscure and faulty browsers aka as IE :) . Knowing that, might seduce a
webauthor into using the child selector without spaces as a 'hack to get
different browsers do different things'. But that certainly was not the intended
use for the child selector.

--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'
 
R

rf

Then why do you come to alt.html?

Probably because the non-existant charter for alt.html includes just about
everything that is done client side.

Besides, these days CSS should be considered an integral part of writing
"HTML".
I've added ciwas, and f'up set hence.

And I have removed it and reset the followups
 
B

Barbara de Zoete

Probably because the non-existant charter for alt.html includes just about
everything that is done client side.

Besides, these days CSS should be considered an integral part of writing
"HTML".

What was the original logic of creating a newsgroup ciwas? Why shouldn't a
discussion on styles, selectors et cetera be better of there?


--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'
 
D

Dylan Parry

Barbara said:
What was the original logic of creating a newsgroup ciwas?

Probably the same logic as that for creating ciwah. Neither of which are
in the same hierarchy as alt.html.
 
B

Barbara de Zoete

Probably the same logic as that for creating ciwah. Neither of which are in
the same hierarchy as alt.html.

The second question remains:

--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'
 
D

Dylan Parry

Barbara said:
The second question remains:

No one is saying that it wouldn't be better off there, but your logic
was stating that "a discussion on styles, selectors et cetera" should
*only* be posted there. This is clearly wrong.
 
R

rf

Barbara de Zoete said:
What was the original logic of creating a newsgroup ciwas? Why shouldn't a
discussion on styles, selectors et cetera be better of there?

Look at the "alt" in alt.html.

Note the absense of "alt" in ciwas.

alt means alternative. No holds bared. Anything goes.

ciwas (and the rest of the big 8) have their place, as die hard stick with
the rules places where one can only talk about CSS and nothing else. Drift
off into javascript over there and you are in deep shit. You will be
referred to clj and then you will be admonished for multiposting!

Here we diverge.

ciwas is the technicians dining room. alt.html is the local pub.

I personally audit many of the c* groups. I only post to alt goups, when I
remember where I am :)
 
B

Barbara de Zoete

No one is saying that it wouldn't be better off there, but your logic was
stating that "a discussion on styles, selectors et cetera" should *only* be
posted there. This is clearly wrong.

It could be, if I stated that. Which I didn't.
The context of the question of OP pointed to ciwas as more appropriate, as there
was no markup related topic at all. More appropriate. It is not unusual to move
a discussion to another newsgroup if it is a more appropriate group.

--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'
 
B

Barbara de Zoete

Look at the "alt" in alt.html.

Note the absense of "alt" in ciwas.

alt means alternative. No holds bared. Anything goes.

In the hierarchy alt.* anything goes for sure. In a named group, like alt.html,
there are things on topic and off topic. If anything goes, how about a
discussion on fuel shortage in the coming decade?

--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'
 
R

rf

Barbara de Zoete said:
In the hierarchy alt.* anything goes for sure. In a named group, like alt.html,
there are things on topic and off topic. If anything goes, how about a
discussion on fuel shortage in the coming decade?

Fuel shortages would probably be off topic for alt.html. Have you visited
alt.www.webmaster recently?
 
B

Barbara de Zoete

Fuel shortages would probably be off topic for alt.html.
lol

Have you visited alt.www.webmaster recently?

I never go there. I'm suspicious about all said by one who claims to be a
web_master_. Anything interesting in that group?


--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'
 
D

Dylan Parry

Barbara de Zoete wrote:

[alt.www.webmaster]
Anything interesting in that group?

Yes, sometimes. It's less technical than even alt.html, and generally
less on-topic. There has been a much greater number of marked OT posts
there recently, but the occasional good discussion arises. A lot of the
folk who frequent here also post there too, but I find it a more
"relaxed" and general group than alt.html.
 
W

WebMaster

Barbara de Zoete said:
In the hierarchy alt.* anything goes for sure. In a named group, like alt.html,
there are things on topic and off topic. If anything goes, how about a
discussion on fuel shortage in the coming decade?

there won't be any shortage. We had that topic back in the seventies too
(and in the eighties, and...) :)
There will be higher prices (due to nonexistent shortage) though (also had
that in the seventies)...

Rudy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top