Forum Moderators: not2easy

Message Too Old, No Replies

input styles affecting textbox, checkbox, button...

         

tim_mackey

10:53 pm on Mar 16, 2004 (gmt 0)

10+ Year Member



hi,
i have a css style for input elements as follows
input{ border: 1px solid #000000; }
this looks nice for text boxes and buttons, but not for checkboxes. does anyone know of an easy way to prevent the above being applied to all checkboxes?
i could use id's for elements that want the style or those that don't, but i'm just wondering is there a syntax like "input>button { blahh....}"

thanks in advance for any help
tim

Purple Martin

11:01 pm on Mar 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You shouldn't use IDs because IDs must be unique. You could use classes instead, because you can use the same class many times in the page: apply the class to all inputs you want to have a border:

input .bordered { ... }

<input class="bordered" ... >
<input class="bordered" ... >
<input class="bordered" ... >

tim_mackey

11:19 pm on Mar 16, 2004 (gmt 0)

10+ Year Member



hi martin, thanks for the quick reply.
it seems to me that html has an unusual grouping of the input controls into one element, differentiated only by a type attribute. it means formatting requires a little more specification in a way like have suggested, which is a bit of a pain.

Purple Martin

12:19 am on Mar 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I agree. On the one hand I can understand why the inventors of HTML wanted all input fields to use the same tag (so why didn't they do the same with textarea?), and on the other hand it would be more useful for us to have a different tag for each type of control. It would make styling easier.

Interestingly, this will be addressed in XHTML 2.0, with the introduction of xforms. There will be different controls such as:

input => text field
select => checkbox
select1 => radio button

Full info at [w3.org...]