471,599 Members | 931 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,599 software developers and data experts.

selector using body class

I wish to select and style elements in a page having a body of a given
class.

<body class="page">
<div class="inside">
<div id="a">
<p>Content of #a</p>
</div>
<div class="b">
<p>Content of class .b</p>
<div class="c">
<p>Content of .c</p>
</div>
</div>
</div>
</body>

I've had trouble selecting the content of #a, .b and .c.

For example, those don't work in the stylesheet:

body.page div.inside #a { style statements }
body.page .b { style statements }
body.page div.inside .b { style statements }
body.page div.c {style statement }

--

Haines Brown, KB1GRM

Nov 2 '07 #1
4 2051
Jukka K. Korpela schreef:
Scripsit Haines Brown:

>I've had trouble selecting the content of #a, .b and .c.

Please post a URL that demonstrates the problem, explain why you think
there is a problem caused by selector issues, and identify the
browser(s) you used for testing.

Haines,

you better follow Jukka's advice and provide us with a URL
because the example you posted is working fine in my browser.

--
Rob
Nov 2 '07 #2
Rob Waaijenberg <ro************@hotmail.comwrites:
you better follow Jukka's advice and provide us with a URL
because the example you posted is working fine in my browser.
Rob,

Indeed. I has a small markup error that killed the whole works, and
when corrected I had no problem getting the selectors to work. Sorry
to have been difficult.

--

Haines Brown, KB1GRM

Nov 3 '07 #3
On Fri, 2 Nov 2007 20:12:17 +0200, "Jukka K. Korpela"
<jk******@cs.tut.fiwrote:
>I wish to select and style elements in a page having a body of a given
class.

Why? There is only one body element on a page, so there's seldom any reason
to assign a class to it.
There's very frequently a reason to class a body element - when you
share an external stylesheet across many pages. This can obviously be
sub-types of page within a site. It could even be a simple way to
roll-out Google-like date-based rebranding of a page simply by flipping
<bodyto <body class="halloween" >
Nov 3 '07 #4
Scripsit Andy Dingley:
There's very frequently a reason to class a body element - when you
share an external stylesheet across many pages.
I think it would be more natural to use distinct stylesheets, with @import
directives taking care of using those rules that should be applied to all
(or most) pages. This would make the dependancy clearer: this stylesheet
associates with this page, as opposite to coding the dependancy into
selectors and therefore making selectors (which can be rather complicated
for other reasons) more complicated.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Nov 3 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Richard Barnet | last post: by
4 posts views Thread by Zane | last post: by
3 posts views Thread by Lian Liming | last post: by
2 posts views Thread by tagbert | last post: by
1 post views Thread by jorgedec | last post: by
6 posts views Thread by _googlepost | last post: by
3 posts views Thread by RobG | last post: by
2 posts views Thread by XIAOLAOHU | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.