This question already has answers here:
Is there a CSS parent selector?
(33 answers)
Closed 7 years ago.
What is the way of getting parent element using pure CSS. Am using VS 2013, So it must be css3. I have seen in google about has() and < selectors. Unfortunately they do not work.
There is parent selector in css4 $E > F (last in table) where $E is parent of F. Unfortunately there is no support for it (only 26% for whole css4).
Related
This question already has answers here:
Is there a CSS selector by class prefix?
(4 answers)
Can a dynamic class be styled using CSS? [duplicate]
(2 answers)
Closed 7 months ago.
I have a targeting problem in CSS:
I would like to target an element with 2 classes, one of which begins with a prefix.
like this: <div class=firstclass secondclass">
i used this css selector but it doesn't work.
[class^="second"].firstclass {}
Could you please help me?
thx
This question already has an answer here:
CSS data attribute conditional value selector?
(1 answer)
Closed 6 years ago.
I want to write this in CSS li[tabindex > '5'] {} to select all tabindex which have a number greater than 5. Is it possible ?
This can´t be made with CSS.
I am no expert with javascript so I can´t provide you the code, but I´m sure you can achieve it with js.
maybe this gives you a good start:
jQuery: Selecting all elements where attribute is greater than a value
This question already has answers here:
Combining :last-child with :not(.class) selector in CSS
(2 answers)
Can I combine :nth-child() or :nth-of-type() with an arbitrary selector?
(8 answers)
Closed 8 years ago.
I’m looking for a way to target the last of a certain type, but exclude the very last child that has a class name (if it exists). So I tried this:
p:not(.last):last-of-type{color:red}
to target the two in this markup:
<p>one</p>
<p>two</p>
<p class="last">three</p>
I was thinking that it would first select all P’s that doesn’t have the class "last", then filter out the last of those. But I’m obviously wrong here. Is there any other way?
Here is a fiddle: http://jsfiddle.net/365t5mew/
This question already has answers here:
Should I use single or double colon notation for pseudo-elements?
(6 answers)
Closed 9 years ago.
I've noticed that both : and :: work when marking up pseudo elements in CSS. I'm sure there is some semantic difference between the two, no? I'm not really seeing it.
From the CSS3 selector specification section on pseudo-elements:
This :: notation is introduced by the current document in order to establish a discrimination between pseudo-classes and pseudo-elements. For compatibility with existing style sheets, user agents must also accept the previous one-colon notation for pseudo-elements introduced in CSS levels 1 and 2 (namely, :first-line, :first-letter, :before and :after). This compatibility is not allowed for the new pseudo-elements introduced in this specification.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Complex CSS selector for parent of active child
How would I make a css selector with that applies style to a table cell that has an input child element?
Unfortunately, you can't target parent elements in CSS yet (I believe it will come in CSS3)(see Sam's answer). If you want to do this, you'll either have to a) use javascript or b) add a class name to the td containing the input.
Here is a nice reference of the selectors you can use currently to target children, siblings, types, etc.
According to Wikipedia:
Selectors are unable to ascend
CSS offers no way to select a parent or ancestor of element that satisfies certain criteria. A more advanced selector scheme (such as XPath) would enable more sophisticated stylesheets. However, the major reasons for the CSS Working Group rejecting proposals for parent selectors are related to browser performance and incremental rendering issues.
And for anyone searching SO in future, this might also be referred to as an ancestor selector.
If you're using jQuery:
$("td input").each(function() { $(this).parent("td").css("style", "value"); });