473,513 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Nested CSS Classes, Inheritance

I'm hoping this technique is possible.
Explaining the following code, I want to be able to format the text of
a subclass, depending on who their parent is.

For example, all child elements nested within <div> tags that has a
class=para, will either get underlined or bolded depending on their
parent (theme or section). The importance is that the children has a
class of "para", but that they should be formatted a certain way
depending on their parent.

APPRECIATE IT IF ANYONE CAN HELP.

<style>
div { font-family: Arial; }
div.theme { color: #000099; }
div.section { color: #990000; }
..section.para { font-weight: bold; }
..theme.para { text-decoration: underline; }
</style>

<body>
<div class="theme">
<div class="para">
THEME
</div>
</div>
<div class="section">
<div class="para">
SECTION
</div>
</div>

</body>
Jul 20 '05 #1
3 61437
da********@hotmail.com (Danny) writes:
For example, all child elements nested within <div> tags that has a
class=para, will either get underlined or bolded depending on their
parent (theme or section). The importance is that the children has a
class of "para", but that they should be formatted a certain way
depending on their parent.
Look up descendant selectors in the CSS specification or a tutorial.
http://www.w3.org/TR/CSS2/
.section.para { font-weight: bold; }
..section .para {...}
.theme.para { text-decoration: underline; }


..theme .para {...}

--
Chris
Jul 20 '05 #2
da********@hotmail.com (Danny) wrote:
Explaining the following code, I want to be able to format the text of
a subclass, depending on who their parent is.

For example, all child elements nested within <div> tags that has a
class=para, will either get underlined or bolded depending on their
parent (theme or section). The importance is that the children has a
class of "para", but that they should be formatted a certain way
depending on their parent.

.section.para { font-weight: bold; }


You need a space in there.

..section.para matches any element with class="section para"
..section .para matches the inner element that in
<XXX class="section"><XXX class="para">
which is what I think you're describing here.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 20 '05 #3
Hey Chris and Steve, thanks for your reply....worked like a charm...to
think, all i needed was that ONE SPACE, and it would've
worked......what a waste of a day trying to figure it out on my own.

MUCH APPRECIATED,
Steve Pugh <st***@pugh.net> wrote in message news:<p9********************************@4ax.com>. ..
da********@hotmail.com (Danny) wrote:
Explaining the following code, I want to be able to format the text of
a subclass, depending on who their parent is.

For example, all child elements nested within <div> tags that has a
class=para, will either get underlined or bolded depending on their
parent (theme or section). The importance is that the children has a
class of "para", but that they should be formatted a certain way
depending on their parent.

.section.para { font-weight: bold; }


You need a space in there.

.section.para matches any element with class="section para"
.section .para matches the inner element that in
<XXX class="section"><XXX class="para">
which is what I think you're describing here.

Steve

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
4521
by: Paul Morrow | last post by:
I'm hoping that someone can explain why I get the following exception. When I execute the code... ###################################### class Parent(object): class Foo(object): baz = 'hello...
4
4003
by: KInd | last post by:
Hello All, When is nested class more preferable that Inheritance ? I think with proper inheritance and friend class concept we can get the same flexibility as nested classes Any comments .. Best...
13
3284
by: Markus Ernst | last post by:
Hello In a content administration tool I call classes from inside classes in order to separate the admin functions from the display-only functions: class book { var $title; var $author;...
3
1313
by: Luis Diego Fallas | last post by:
Hi everyone , I'm having a problem when trying to compile code that contains the following pattern: using System; public class A { public class B : Inn.C { }
4
1964
by: Christopher Ireland | last post by:
Hi -- I'm trying to find an example of a nested class implemented within the .NET Framework itself but without much success. I don't suppose that anybody knows of such an example off the top of...
11
2690
by: C# Learner | last post by:
Is it not possible to declare a nested class in a seperate file from its "parent" class -- i.e. in a similar way to the idea of spreading namespaces over more than one file?
7
2399
by: Ryan Shaw | last post by:
I’m having a small problem with inheritance with a hierarchy of classes The example is Class Class Private m_classB as Class Class Class End Clas End Clas
3
2056
by: Martin Skou | last post by:
I'm experimenting with using Python for a small web interface, using Mark Hammond's nice win32 extensions. I use a small class hierarchy which uses inheritance and nested classes. Here are a...
2
2357
by: miked | last post by:
I am architecting in a read only class for use in mapping data to a business object. The object makes strong use of nested classes and their ability to access protected fields. The downside is...
9
3446
by: stephen.diverdi | last post by:
Can anyone lend a hand on getting this particular template specialization working? I've been trying to compile with g++ 4.1 and VS 2005. ...
0
7260
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,...
0
7161
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...
1
7101
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5686
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,...
1
5089
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...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1596
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
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...

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.