0

I am trying to select a parent div in google earth which it doesnt have any id or class and it it is just a div element. I used this method

div < div.well {background-color: red !important; }

since the div contains another div with the class of .well but this seems not working! can you please let me know what i am doing wrong?

Thanks

Update

Please Look at This Jsfiidle

Mona Coder
  • 5,750
  • 15
  • 55
  • 103

4 Answers4

1

As of now there's no construct in CSS to select parent elements. For more info on the subject, check this:

Is there a CSS parent selector?

Community
  • 1
  • 1
Leniel Maccaferri
  • 94,281
  • 40
  • 348
  • 451
0

Unfortunately CSS does not give us a way to select parents. You can select it as a descendant of it's own parents thought. Maybe provide some more context or some source code so we can help more.

Gabriel
  • 16,614
  • 2
  • 34
  • 41
0

I dont know the context here, but if you can't modify the html, this is possible with jQuery as follows:

<script>
jQuery('div.well').parent('div').css('background', 'red');
</script>

As others have noted, there is no CSS solution.

-1

HTML:

<meta charset=utf-8 />
<div>First div.
<div><div class="well">Second</div>
<div>Third

CSS

div > div.well { background: red; }

JsBin: http://jsbin.com/aaddj/1/edit?html,css,output.

EDIT: before complaining/editing about the syntax, watch this: http://www.youtube.com/watch?v=WxmcDoAxdoY. The html5 parser is smarter than us.

EDIT2: Here is a fiddle forked from OP's working: http://jsfiddle.net/MEhUj/.

Esteban
  • 3,030
  • 3
  • 29
  • 51
  • Thanks Esteban but this is not working on my example! can you please take alook at updated jsfiddle? – Mona Coder Oct 02 '13 at 23:44
  • 1
    Have you noticed the `>` instead of ` div.well {background-color: red !important; }`. – Esteban Oct 02 '13 at 23:45
  • but how come it is not grabbing that div (the white one around well? – Mona Coder Oct 02 '13 at 23:51
  • It **only** selects the div tags containing another `div` with the `well` class. – Esteban Oct 02 '13 at 23:53
  • The HTML5 parser parses HTML5, not CSS. Just FYI. Unless you were referring to the lack of a doctype or html/head/body tags and not the incorrect CSS syntax, in which case you really need a doctype for most things. – BoltClock Oct 03 '13 at 00:23
  • I was pointing out, because people like to complain about a lot, its faster to write to answer a question, since i dont have that much time. I **know** what the parser do, and i believe that html5 will place the doctype there if you missed it. – Esteban Oct 03 '13 at 01:06
  • My answer works, so there is no need for a downvote :) – Esteban Oct 03 '13 at 01:07
  • 1
    "i believe that html5 will place the doctype there if you missed it" No. The whole point of a doctype is that you need to declare it yourself. Also, since you said yourself that you're using `>`, what makes you so sure you're selecting the parent and not the child? I don't see why you need to be so smug either. – BoltClock Oct 03 '13 at 02:39