Re: Selector "on presence of"

Ian Hickson wrote:
> 
> > Would it make sense to have a selector that makes the rules apply only
> > if a certain other element is present/not present?
> > This could be laid out as a letter, no problem, but if the sender wanted
> > to add something like a company logo, the layout would need some
> > corrections, which could be made in a special rule which would only
> > apply if a IMG.logo was present.
> 
> Why not just apply the rule to the IMG.logo element? (position it, etc).
> 
> However, I do like the idea of a selector which applies to elements matching
> some condition based on other information gathered from the tree.
> 
> What about this: A pseudo-class like the :lang() pseudo-class, which accepts
> as parameter a css selector. If the selector given as a paramter applies to
> anything, then the rule applies to the main selector.

The problem is that all the current selectors and qualifiers,  including
things like :first-child, sibling and attribute values,  are
deterministic and fairly quick.  If you search for a specific element in
the document (in general) you need to do a full search of the entire
document to satisfy each of these qualifiers.  That makes it pretty
impractical.

The pattern language has to be a balance of functionality for the author
as well as practicality for the implementor.  You can get the effect you
want in CSS1 with a class or id,  and in CSS2 you can check for other
attribute values.

Doug

-- 
Doug Rand				drand@sgi.com
Silicon Graphics/SSO			http://reality.sgi.com/drand
Disclaimer: These are my views,  SGI's views are in 3D

Received on Friday, 5 June 1998 10:34:49 UTC