Jump to content

radio button css


Raz Tibi

Recommended Posts

hello there,

 im having a trouble in changing the color of the text when radio button is checked. 

https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_custom_radio - i copied the try it yourself code from this website,

and i cant seem to understand how can i change the color of the label since its in the container it self,

 every other website use the <input> property and then <label>

so in the css file its written like

input:checked + label{},

yet this solution doesn't apply here,

 

Link to comment
Share on other sites

The label can be bound to a input using the 'for' attribute to target the inputs id reference. To target the text you must wrap the text in a element such as span, because css cannot target the parent element yet! When the bound label of radio button Or the radio button itself are clicked to will become :checked, then it cascades down to the sibling elements (span) to change the styling.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...