Re: Nested and non-nested elements: pseudoclasses

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
> >non-nested elements not being capable of responding to other elements
> >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
> >another element (DIV) that should respond to the <a class="hovered">
> >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*
> >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
> >be a cross-platform, accessible replacement to JavaScript and DHTML.
> >simple tasks as this are not possible as they should be.  *However*, it
> >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 UTC