Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

border around text input in a html form

Tags:

html

css

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!

like image 344
leofer Avatar asked Mar 21 '12 09:03

leofer


People also ask

How do you put a border on an input box in HTML?

You can use the CSS border property to add a border around your HTML textboxes. You can also use border-width , border-style , and border-color , but the border property covers all of these anyway.

How do I add a border to a form?

Set form content into fieldset (just after the form and before the /form), set Title into the fieldset, at the first line, and set a border (2px solid #000, for example) on the fieldset. Save this answer.

How do you style text inside input field?

Styling Input Fields If you only want to style a specific input type, you can use attribute selectors: input[type=text] - will only select text fields. input[type=password] - will only select password fields. input[type=number] - will only select number fields.


1 Answers

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/

like image 53
giftcv Avatar answered Oct 11 '22 02:10

giftcv