W3C home > Mailing lists > Public > www-style@w3.org > June 2005

Re: Toggling a CSS property

From: Larry Israel <lisrael@cruzio.com>
Date: Thu, 23 Jun 2005 02:03:38 -0700
Message-Id: <a06210216bee024ee4676@[192.168.1.104]>
To: www-style@w3.org
Cc: Stephen R Laniel <steve@laniels.org>

Stephen R Laniel wrote:
> I wonder if there's a way to address the problem I describe below
> using CSS2; I've not found any way to do it, and I've been looking
> for a while.
[...]
> <span class="booktitle">An analysis of Hitchcock's
> <span class="filmtitle">Rear Window</span>
> </span>
>
> Then in the CSS, I want to do something like
>
> .booktitle, > .filmtitle {
> 	font-style: italic;
> }
>
> .booktitle > .filmtitle, .filmtitle > .booktitle {
> 	font-style: normal;
> }
>
> But there's a combinatorial explosion here, because I also
> have HTML classes like "courtcase" and "newspaper" defined,
> all of which also require italics and also require the
> italics to be turned off if one class is inside the other.
>
> I'd like to be able to say in general, somehow, that if a
> element is formatted to use italics, and it's inside another
> element that's formatted to use italics, then the inner
> object should use a roman font. And this should work at
> arbitrary depth -- a book title within a movie title within
> a book title (rare as that would be) should be italicized.

This list is for discussion of changes to CSS specifications. This is not
a "how-to" list, but your question seems to be along those lines, which
may be why no one has replied.

The CSS-D list is for practical discussions of CSS and its use:
http://www.css-discuss.org/mailman/listinfo/css-d

The universal selector * might help you (or might not), depending on the
details of your markup. For example:

.booktitle, .filmtitle {
	font-style: italic;
}

.booktitle *, .filmtitle * {
	font-style: normal;
}

.booktitle * *, .filmtitle * * {
	font-style: italic;
}

.booktitle * * *, .filmtitle * * * {
	font-style: normal;
}

However, this won't work as you intend if some of these spans contain
other elements or classes (which are not part of your italics group).

Larry
http://larry.israel.name
Received on Thursday, 23 June 2005 09:03:55 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:37 GMT