From: Mark Smith on
Is it possible to select elements conditionally based on what they
contain?

For example, is there a combination of CSS selectors that would select
all divs that do not contain a span?

Thanks
From: Thomas 'PointedEars' Lahn on
Mark Smith wrote:

> Is it possible to select elements conditionally based on what they
> contain?

Not with CSS.

> For example, is there a combination of CSS selectors that would select
> all divs that do not contain a span?

No. What do you need this for?


POintedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
From: Mark Smith on
On May 26, 5:53 pm, Thomas 'PointedEars' Lahn <PointedE...(a)web.de>
wrote:
> Mark Smith wrote:
> > Is it possible to select elements conditionally based on what they
> > contain?
>
> Not with CSS.
>
> > For example, is there a combination of CSS selectors that would select
> > all divs that do not contain a span?
>
> No.  What do you need this for?
>

I have a table generated in the format of

<table>
<thead>
<tr><th><span class="X">...</span></th><th><span
class="Y">...</span></th><th><span class="Z">...</span></th></tr>
</thead>
....

I want to hide the column headers that contain spans of certain
classes.

Was hoping it would just be a styling change, but looks like I have to
hack the library now to apply the class to the actual TH elements as
well...
From: Andy Dingley on
On 26 May, 14:49, Mark Smith <marksmith5...(a)jungle-monkey.com> wrote:
> Is it possible to select elements conditionally based on what they
> contain?

You're looking for predicates, and in general there isn't any such
mechanism in CSS (look at XPath for an example of one).

If you read Haakon Lie's PhD thesis, the rationale behind these
decisions is explained more fully. CSS is in many ways a reaction to
previous stylesheet languages, such as DSSSL, and their over-
complexity. An axiomatic assumption behind CSS is that it will only
need to be applied to documents that are the output from a fairly
sophisticated publishing process (i.e. it can reasonably make demands
that these documents contain extra markup to assist CSS), rather than
optimised for terseness and simplicity of coding them. This allows
significant simplifications in CSS itself, achieving clarity of the
CSS specification, and also simplicity of CSS implementations.

The "CSS way" of working is that rather than writing complicated CSS
selectors that can infer a lot from document structure, you write
documents with additional explicit classes where this implied
condition would be met. The CSS is then an easy match for a class. You
are forced to pre-process the HTML (or hand-edit) to achieve this.
This is easier and simpler overall, even if it is indeed shifting work
from the browser coder to the site author.
From: David Stone on
In article
<43080329-d505-440a-ac09-e1cddca51e39(a)a16g2000vbr.googlegroups.com>,
Mark Smith <marksmith5555(a)jungle-monkey.com> wrote:

> On May 26, 5:53 pm, Thomas 'PointedEars' Lahn <PointedE...(a)web.de>
> wrote:
> > Mark Smith wrote:
> > > Is it possible to select elements conditionally based on what they
> > > contain?
> >
> > Not with CSS.
> >
> > > For example, is there a combination of CSS selectors that would select
> > > all divs that do not contain a span?
> >
> > No.  What do you need this for?
> >
>
> I have a table generated in the format of
>
> <table>
> <thead>
> <tr><th><span class="X">...</span></th><th><span
> class="Y">...</span></th><th><span class="Z">...</span></th></tr>
> </thead>
> ....
>
> I want to hide the column headers that contain spans of certain
> classes.
>
> Was hoping it would just be a styling change, but looks like I have to
> hack the library now to apply the class to the actual TH elements as
> well...

Why not just class the th and drop the span? Reduces the markup...
 |  Next  |  Last
Pages: 1 2 3
Prev: positioning absolute
Next: Sidebar tops uneven