De Facto Standard for Input[type=text] Class

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

De Facto Standard for Input[type=text] Class

Post by JellyFish »

As you may already know, IE6 (and I believe IE7, not sure about IE8 though) does NOT support CSS attribute selectors. That is, these:

Code: Select all

input[type=text] { /*...*/ }
So, the only way to select a input element with the type of text (input boxes, which is what I call them) I would need to add a class to them and write:

Code: Select all

input.text { /*..*/ }
But when I think about it, the class text doesn't seem to be very suitable, and almost sounds like a more textual element.

So! My question is this:

What's the de facto standard for a css class for this specific purpose? What classes should I give to each input element? Should I just go with .text for all input[type=text]'s and .button for all input[type=button]'s, and etc?

Any suggestions are appreciated. Thanks for reading.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: De Facto Standard for Input[type=text] Class

Post by pickle »

The idea is to be as semantic as possible, so using .text and .button would seem to make sense.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Re: De Facto Standard for Input[type=text] Class

Post by JellyFish »

pickle wrote:The idea is to be as semantic as possible, so using .text and .button would seem to make sense.
Does it? I wonder, because it would seem that anything that has the class "text" would have to be text. But I guess sense a input text box has text in it, it makes sense.

Okay I'll go with that. I just wanted to make sure that there might be some issues down the road if I used this class for this purpose.

PS: It almost seems like I get caught up with naming conventions so much that I need some concurrence by other developers, as if I'm always asking "I this good idea...Is this okay?" I wonder why that is and how I can get over that. :P
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: De Facto Standard for Input[type=text] Class

Post by kaszu »

I usually use "text" and in CSS "input.text" for input and "div.text" for text blocks. Haven't had any problems with this.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: De Facto Standard for Input[type=text] Class

Post by pickle »

It's a good idea to use ".text" and ".button" as opposed to ".blue" and ".small_rounded" for classes. This future-proofs your classes because if you want to change how the site looks, you can change the .text class & the meaning can persist. Using ".blue" for example, won't be as meaningful if you change the text to black.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply