0

Hi I would like to target and modify the <label> tag only when is next to a input[type=radio], no in any other cirscuntances.

My code looks like this:

<fieldset>
  <legend>Some legend</legend>
  <p>Some explanation</p>
  <label>
   <input type="radio" name="#{name}" value="#{value}" />
  </label>
</fieldset>

I tryied with fieldset label:first-child+input[type=radio]{} but doenst work, if someone can help me would be awesome.

EDIT: What I want is to be able to style only the LABEL tag no the RADIO button INPUT tag, and this style will apply only when <label><input type="radio"></label> structure is found.

BoltClock
  • 630,065
  • 150
  • 1,295
  • 1,284
ncubica
  • 7,276
  • 7
  • 50
  • 67

1 Answers1

3

What you are asking for is not possible in CSS. It is not possible to traverse "back" or "up" the DOM tree (so you can't target previous siblings or parent nodes).

See this post: Is there a CSS parent selector?

Community
  • 1
  • 1
skyline3000
  • 6,896
  • 1
  • 20
  • 32