-4

There is no parent selector even with css3 but I would like to suggest in css4 we could select parent selector as this

As for child

E > F Matches any F element that is a child of an element E.

So far for parent

E < F Matches any E element that is a parent of an element F.

As for immediately precedent sibling

E + F Matches any F element immediately preceded by a sibling element E.

So far for immediately decedent sibling

E - F Matches any F element immediately decedent by a sibling element E.

As for precedent sibling

E ~ F Matches any F element preceded by a sibling element E.

So far for decedent sibling

E ^ F Matches any F element decedent by a sibling element E.

Hope this would be very useful to all.

James Donnelly
  • 126,410
  • 34
  • 208
  • 218
Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231
  • 1
    I don't think that is going to happen. I believe that using child to ancestor relationships is expensive and comes with a number of issues. But you never know. – hungerstar Jul 26 '13 at 07:50
  • possible duplicate of [Is there a CSS parent selector?](http://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector) – Sirko Jul 26 '13 at 07:51
  • 1
    There is a spec to specify the subject of a CSS rule, which can be used as a parent selector: [W3C](http://www.w3.org/TR/selectors4/#subject). It is currently not implemented, but you are not the first with that idea ;-) – Sirko Jul 26 '13 at 07:52
  • I'll be watching this and that other question to see if it gets implemented... but think about what you want. – icedwater Jul 26 '13 at 08:02
  • This doesn't seem like a good question for SO – sulfureous Jul 26 '13 at 08:16

2 Answers2

1

where can I suggest for new css rule?

Suggestions for changes to CSS are best addressed to the www-style@w3.org mailing list.

See How To Help from the CSS Working Group.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Keep in mind you'll probably get mercilessly shot down - or at least whisked away to the existing Selectors 4 draft - for suggesting anything like in the given question. Those topics are just about as dead a horse in the mailing list as they are here. – BoltClock Jul 26 '13 at 11:40
  • Indeed. See the second paragraph of the How To Help section. – Quentin Jul 26 '13 at 11:54
0

Do you really want background-color: green; to bubble up from a box on the side of your page to every parent, including <body> and then <html>? It would involve lots of wildcards, and redefining parent element styles later on in the stylesheet to make sure things worked right.

We would lose hair twice as fast, I think...

icedwater
  • 4,701
  • 3
  • 35
  • 50
  • 1
    I think you're confusing ancestor selectors with the `inherit` keyword... – BoltClock Jul 26 '13 at 11:43
  • Maybe. But if you want a style to apply to all parents of `x`, wouldn't you have to make sure subsequent rules don't overwrite them? – icedwater Jul 27 '13 at 00:49
  • 1
    The same can already be done with descendant selectors, so that's not going to be a new issue. Borders don't inherit unless you specify it, so it won't be difficult to override. – BoltClock Jul 27 '13 at 06:29