8

I want a red border around my input text fields in a html form. But using css

input { border: 1px solid #d66 }

also puts a red border around my buttons (which I don't want).

input.button, input.submit or input.text and anything inside { } doesn't do anything.

How do I change the border around a text input only, and how do I change the font in the submit button only? I'm using IE9.

Thanks!

2 Answers 2

16

To target textboxes, use

input[type="text"] { border: 1px solid #d66 }

There are a lot more attribute selectors available.

Have a look at http://css-tricks.com/attribute-selectors/

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

Comments

4

What you need is an attribute selector:

input[type="text"] { border: 1px solid #d66 }

This selects the input of type "text."

You can also use other attribute selectors to select other elements:

input[type="submit"] { border: 1px solid #d66 }
input[type="checkbox"] { border: 1px solid #d66 }

But also be aware that these selectors are not supported by IE7 and lower.

Comments

Your Answer

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