0

Is it possible to define css style for checkbox in a form without define id and class for it? I know i can use

input {css...}

but i will effect all the inputs in the form.

3 Answers 3

3
input[type="checkbox"]{...}

There is still some issue with old browsers not recognizing it (IE6 for example) but there are work-arounds to deal with it, if that support is needed.

Sign up to request clarification or add additional context in comments.

Comments

2

Like this, using attribute selectors:

input[type="checkbox"] {
    css...
}

Just be aware that IE6 does not support this. Apart from that, browser support is pretty good.

1 Comment

nickf is absolutely right but just be aware that you will only have a limited amount of styling that you can do with just css when it comes to check boxes and radio buttons. If you want to completely restyle it then you will need to use something like: lipidity.com/fancy-form
1

In addition to attribute selectors, you can, in some newer browsers, use several different pseudo-classes, for example:

<form>
  <input type="text" />
  <input type="text" />
  <input type="text" />
</form>

to target the second input:

input:nth-child(n) {        
  css-property: value;
}

1 Comment

a personal question ... are you really 91 ?!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.