0

I am trying to get my radio button to work as fancy buttons instead of just dots as they are by default, a question has crossed my mind. Many websites/snippet got it like

 <input id="rad1" type="radio" name="rad"><label for="rad1">Radio 1</label>
<input id="rad2" type="radio" name="rad"><label for="rad2">Radio 2</label>

but the semantic mark up is more like

   <label for="rad1"><input id="rad1" type="radio" name="rad">Radio 1</label>
    <input id="rad2" type="radio" name="rad"><label for="rad2">Radio 2</label>

does the later markup is valid, as people are more able to control the layout

input[type="radio"]:checked+label{ font-weight: bold; } 

but isn't the latter real valid?

Community
  • 1
  • 1
localhost
  • 822
  • 2
  • 20
  • 51

1 Answers1

0

From my experience with markup languages everything looks fine in your example. If you really want to check your inputs, you can do so by putting them in one of this basic validators here -> https://validator.w3.org/#validate_by_input. I hope this answers your question!

Vlad Balanescu
  • 664
  • 5
  • 27