Connecting Tech Pros Worldwide Help | Site Map

styling input type

  #1  
Old November 17th, 2008, 08:05 PM
Jeff
Guest
 
Posts: n/a
I needed to to do a quick width set for form input type="text",

So:

input{
width: 200px;
}

That also styled all my radio buttons!

Is it possible to set a style for just one type?

Jeff
  #2  
Old November 17th, 2008, 09:25 PM
dorayme
Guest
 
Posts: n/a

re: styling input type


In article <rbWdnbJlFYQyUbzUnZ2dnUVZ_sninZ2d@earthlink.com> ,
Jeff <jeff@spam_me_not.comwrote:
Quote:
I needed to to do a quick width set for form input type="text",
>
So:
>
input{
width: 200px;
}
>
That also styled all my radio buttons!
>
Is it possible to set a style for just one type?
>
Perhaps look at

<http://www.w3.org/TR/html401/interact/forms.html#adef-size-INPUT>

17.4 The INPUT element

size = cdata [CN]
This attribute tells the user agent the initial width of the control.
The width is given in pixels except when type attribute has the value
"text" or "password". In that case, its value refers to the (integer)
number of characters.

--
dorayme
  #3  
Old November 17th, 2008, 10:45 PM
Jonathan N. Little
Guest
 
Posts: n/a

re: styling input type


Jeff wrote:
Quote:
I needed to to do a quick width set for form input type="text",
>
So:
>
input{
width: 200px;
}
>
That also styled all my radio buttons!
>
Is it possible to set a style for just one type?
Yes

input[text] {...}

It is called an *attribute* selector.

http://www.w3.org/TR/CSS21/selector....bute-selectors

But, before you get too excited, realize that IE does not support
attribute selectors...


--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
  #4  
Old November 17th, 2008, 10:45 PM
Chris F.A. Johnson
Guest
 
Posts: n/a

re: styling input type


On 2008-11-17, Jeff wrote:
Quote:
I needed to to do a quick width set for form input type="text",
>
So:
>
input{
width: 200px;
}
>
That also styled all my radio buttons!
>
Is it possible to set a style for just one type?
Yes. Add a class to your text input and style that.

HTML: <input class="text" .... >

CSS: input.text { width: 15em; }

(I would avoid using px to set the width.)

--
Chris F.A. Johnson <http://cfaj.freeshell.org>
================================================== =================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
  #5  
Old November 18th, 2008, 02:55 AM
Jeff
Guest
 
Posts: n/a

re: styling input type


Chris F.A. Johnson wrote:
Quote:
On 2008-11-17, Jeff wrote:
Quote:
> I needed to to do a quick width set for form input type="text",
>>
>So:
>>
>input{
> width: 200px;
>}
>>
>That also styled all my radio buttons!
>>
> Is it possible to set a style for just one type?
>
Yes. Add a class to your text input and style that.
>
HTML: <input class="text" .... >

I would prefer to set all, and then unset the few I don't want. There's
way to many classes in the typical stylesheet.

Is there a way to revert back to the default, unset width after it
has been set?



<style type="text/css">
input{
width: 15em;
}

..default_class{
width: what unsets width?
}

</style>

<input type="text" ...>
<input type="radio" class="default_class">

Jeff

Quote:
CSS: input.text { width: 15em; }
Quote:
>
(I would avoid using px to set the width.)
>
  #6  
Old November 18th, 2008, 04:25 PM
Jukka K. Korpela
Guest
 
Posts: n/a

re: styling input type


Jonathan N. Little wrote:
Quote:
Quote:
> Is it possible to set a style for just one type?
>
Yes
>
input[text] {...}
No, the correct syntax is
input[type="text"] {...}

The selector input[text] would match an input element with an attribute
named text, i.e. <input text="..." ...>, and there's no such element of
course.
Quote:
But, before you get too excited, realize that IE does not support
attribute selectors...
IE 7 does, in "standards" mode.

Interestingly, IE 7 interprets that the selector also matches an input
element with no type attribute, apparently based on the idea that
type="text" is the default. I think this violates the specifications, since
the selector should match only an element that actually has the attribute
type="text" in markup. Firefox seems to agree with me.

Of course, independently of such support issues, a text input element should
always have the size="..." attribute, so that its size is at some level
defined even when CSS is off; see the CSS Caveats,
http://www.cs.tut.fi/~jkorpela/css-caveats.html

--
Yucca, http://www.cs.tut.fi/~jkorpela/

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
input type=image + changing image John answers 8 September 15th, 2007 09:05 AM
How to align text label and input field's text ? Yohan Blurp answers 5 June 14th, 2007 08:15 PM
Styling input element text? Ed Jay answers 3 October 4th, 2006 11:45 PM
Styling a form for print Garmt de Vries answers 3 November 23rd, 2005 03:38 AM