473,599 Members | 3,118 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2149
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.comwri tes:
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.tu t.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="hallowee n" >
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2102
by: | last post by:
I am hoping a mixed ASP- Javascript programmer could help me with this scenario: I have a list box populated with randomized records (NewID()) from a Broker (Salesperson) sql server table. Each time the user selects one of the broker items I need to display a Image of the broker in the table cell next to it. I have found a number of online js scripts that use the image selector route
6
2320
by: Richard Barnet | last post by:
Dear CSS gurus, My question regarding 'the cascade' is a simple one, but one that I haven't heard anyone talk about before: When cascading (for instance, when applying two linked stylesheets), does the whole selector definition supercede and replace a previous one, or does it go through the selector definition line by line (rule by rule) and only supercede rules and attributes that are previously defined?
4
2779
by: Zane | last post by:
Hi, I am having some grieve with the following part of my CSS, basically when using a composite selector using an ID as the first element the it doesn't display the expected results. Am I doing something incorrect? For example my CSS goes something like this: #leftnavbar a:link { color: #333; text-decoration: none; }
3
6609
by: Lian Liming | last post by:
Hi, The language in my web site may be Simplified Chinese or English. I want to define different styles for each language. For each language, the http header is different. <meta name="language" content="en" /> means the language is english <meta name="language" content="zh" /> means the language is Simplified Chinese. Then I use a css selector to define different style for each language. My css code is
2
3855
by: tagbert | last post by:
I'm trying to localize the setting of colors on a series of webpages by defining color palettes that will be used for various page areas. I've defined some palette classes like .clrLt, .clrMd, .clrDk and associated link colors using selectors. One of the aims is to ensure that matching text color, background, and link colors are maintained. These palettes are applied as multiple classes to various page modules which also have abstract...
1
1722
by: jorgedec | last post by:
I have two test vertical menus. If I apply a border-bottom using a selecter of div.vbar a It looks fine. If I apply the border-bottom using a selecter of div.vbar ul li a
6
7189
by: _googlepost | last post by:
I have some CSS that goes something like this: table.TableStyle {font-family: "Helvetica", "Ariel"; background- color:white; border-collapse:collapse;} table.TableStyle COLGROUP { background- color:lavender;} The second line is a style that is applied to a particular named COLGROUP element in tables assigned the TableStyle class. Unfortunately, while this works in most modern browsers (including
3
2001
by: RobG | last post by:
The link below is to a CSS selector test suite that tests 6 popular libraries: <URL: http://ajaxian.com/archives/slickspeed-css-selector-testsuite It might be of interest to some. -- Rob
0
7992
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7904
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8267
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6725
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5850
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3898
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3940
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1505
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1250
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.