W3C home > Mailing lists > Public > www-style@w3.org > August 2004

Re: Nested and non-nested elements: pseudoclasses

From: W. Leon Sutton, Jr. <wsuttonjr@hyponiqs.com>
Date: Thu, 19 Aug 2004 08:09:56 -0400
Message-ID: <002201c485e5$73231320$201d4ed8@hyponiqs>
To: "ACJ" <ego@acjs.net>, <www-style@w3.org>

ACJ Wrote:

> W. Leon Sutton, Jr. wrote:
>
> >It occurs to me that there is a potential 'flaw' in CSS in regards to the
> >:hover and other associated psuedoclasses.  The problem I've come accross
is
> >non-nested elements not being capable of responding to other elements
when,
> >per se, hovered.
> >
> >Take the following example:
> >
> ><p><a class="hovered" href="#">Hover me!</a></p>
> ><p>This is just some filler text to lead by my example.  What will follow
is
> >another element (DIV) that should respond to the <a class="hovered">
element
> >when it's hovered over.</p>
> ><div class="responder">I should show and hide whenever the <a
> >class="hovered"> is hovered and non-hovered.</div>
> >
> >Logically speaking, there should be a way to target an element *anywhere*
on
> >a page using CSS psuedoclasses, such as
> >
> >a.hovered:hover ~ div.responder { display: block; }
> >a.hovered ~ div.responder { display: none; }
> >
> >Why is it that this is not possible?  As I understand it, CSS is supposed
to
> >be a cross-platform, accessible replacement to JavaScript and DHTML.
Yet,
> >simple tasks as this are not possible as they should be.  *However*, it
is
> >possible to apply the same logic to nested elements, but it still
requires a
> >fair amount of CSS.
> >
> >Anyway, this was just a thought.
> >
> >Thanks,
> >Leon Sutton.
> >
> >
> >
> CSS, by no means, is supposed to be a replacement for ECMAScript
> (standardized JavaScript), though--granted--it *is* part of DHTML (which
> is not a standard, but rather a loose collection of technologies
> commonly used for dynamic web pages).

As I understood it, DHTML was simply combining HTML with ECMA-compliant
scripting languages, such as Microsoft JScript, JavaScript, or any other
non-HTML scripting language, such as Microsoft VBScript (don't ask!).  I had
no idea, whatsoever, that CSS was part of DHTML.

Whatever the case, the idea, as far as I was able to interpret from many,
many Web sites and published (non-Internet) documents on the matter, CSS is
supposed to be an accessible replacement to scripting elements to make them
more dynamic.  Why?

Many scripting languages, especially JavaScript and Microsoft JScript,
require scripts to be enabled on the browser.  As the security hype has
increased dramatically in the past few years - thanks to 'skript kiddies'
and would-be hackers - many users are starting to disable scripting
capabilities in their browsers.  However true, the same can be said about
CSS as newer browsers are starting to incorporate a feature that allows a
person to disable CSS styles (or use a set stylesheet instead of the Web
site's set stylesheet).

> Some (including myself) question whether pseudo-classes that are
> "triggered" by user action should even be part of the CSS specs, as it
> seems to be more on the behaviour than the style (appearance) layer, and
> therefor actually *should* be handled by a scripting language like
> ECMAScript.
> I see the :hover pseudo-class as a nice bonus, that lacks flexibility
> but surely makes our (web designers) lives easier. If you *do* want full
> control over actions that are triggered by user input, take it to the
> (proper) behaviour layer.
>
> By the way, how does your example not work?
>
> Sincerly,
>
>
> -ACJ

The problem at hand, now that that's all said, is that I'm trying to find a
way around making elements dynamic, from anywhere on the page, WITHOUT
scripting.  If I wanted to have an element at the bottom of my page appear
when an element near the top of the page is moused over, right now I'd have
to use JavaScript.  CSS only allows for, as far as my experiamentation has
proven, doing this with nested elements (with the exception of IE which only
allow for A elements to have the :hover psuedoclass).

Now, am I missing something?

*NOTE*: Do realize that I do not expect to be able trigger moving elements;
that does require scripting any way you cut it.  I just want to be able to
show and hide non-nested [or non-related] elements using pure CSS.
Received on Thursday, 19 August 2004 12:10:31 GMT

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