Welcome Guest ( Log In | Register )




                Web Hosting Guide

2 Pages V   1 2 >  
Reply to this topicNew Topic
Css For Input Text Only, I don't think there is a solution but...
vdhieu84
post Nov 15 2005, 10:30 PM
Post #1


Member [ Level 1 ]
Group Icon

Group: Members
Posts: 32
Joined: 25-October 05
Member No.: 9,279


I have read (or glimse through) all the CSS 2 specification and google a lot but found no solution for the following problem. Anyone can help?

The basic idea is the input field for the type text, password is quite small, so I want to change its width by CSS

CODE

input {
  width : 400px;
}


However, this affects the width of the radio button too (in most current browser).

Is there anyway that I can apply this CSS to input field which is of the type text or password ONLY?

The tricky part is I MUST NOT use any additional attribute in input field, like class or id...
Go to the top of the page
 
+Quote Post
clagnol
post Nov 15 2005, 11:22 PM
Post #2


Advanced Member
Group Icon

Group: Members
Posts: 102
Joined: 21-August 05
Member No.: 8,003


I rarely work with forms, so I don't have any ideas besides using class/ids. Why exactly are you avoiding the use of class and id?
Go to the top of the page
 
+Quote Post
abhiram
post Nov 16 2005, 01:18 AM
Post #3


Hedonist at large
Group Icon

Group: Members
Posts: 610
Joined: 30-July 05
From: another realm
Member No.: 7,524


Well... without any class or id attribute, I don't think it's possible to do it. Besides, why don't you want to use them?
Go to the top of the page
 
+Quote Post
vdhieu84
post Nov 16 2005, 01:20 AM
Post #4


Member [ Level 1 ]
Group Icon

Group: Members
Posts: 32
Joined: 25-October 05
Member No.: 9,279


Well, I always try to avoid as much class and id as I can since along the way when we writing code, once in a while I will forget to put these attribute in. Even though I will eventually figure out where in my code I missed, it's still better to have a "global" setting which will makes sure consistency for me.
Go to the top of the page
 
+Quote Post
vizskywalker
post Nov 16 2005, 02:42 AM
Post #5


Techno-Necromancer
Group Icon

Group: Members
Posts: 1,018
Joined: 13-January 05
From: The Net
Member No.: 2,127


There is one possible solution, although 1) i have never tested it, and 2) I don't know if it is valid CSS.

Try this:
CODE
input:text {
 width: 400px;
}


The alternative is to simply pecify width in the html tag without using css, or nest the input in a <style> tag.

~Viz
Go to the top of the page
 
+Quote Post
Retaining
post Nov 16 2005, 05:12 AM
Post #6


Member - Active Contributor
Group Icon

Group: Members
Posts: 78
Joined: 1-September 05
Member No.: 8,258


You can match <input> elements that have the type=text property in CSS2 by using the rule "input[type=text] { }". However, I highly doubt that this is fully supported by many browsers, and so your best choice would probably be to nest the input inside a span like viz said.

[note=vizskywalker]Edited on user's Request, next time, report the post instead of making another one though[/note]
Go to the top of the page
 
+Quote Post
Hercco
post Nov 16 2005, 08:51 AM
Post #7


Super Member
Group Icon

Group: Members
Posts: 595
Joined: 4-September 04
Member No.: 228


QUOTE(Retaining @ Nov 16 2005, 07:12 AM)
You can match &lt;input&gt; elements that have the type=text property in CSS2 by using the rule "input[type=text] { }".  However, I highly doubt that this is fully supported by many browsers, and so your best choice would probably be to nest the input inside a span like viz said.
[right][snapback]60789[/snapback][/right]



This is the way to do it. It is good coding style to define the type attribute for all form fields, although "text" is assumed the default.

This is in fact supported in many browsers, but not in Internet Explorer (surprise, surprise rolleyes.gif) Usually this isn't a problem as CSS is most of the time used to change the form field colours, backgrounds, borders; stuff that IE users can do without. But width is something you gotta get right on every browser.

If you really need the option and can't come up with other solution, you might wish to try Dean Edwards IE7: http://dean.edwards.name/IE7/ It fixes most if IE CSS issues, with no need for users to install anything.
Go to the top of the page
 
+Quote Post
Hercco
post Nov 16 2005, 08:53 AM
Post #8


Super Member
Group Icon

Group: Members
Posts: 595
Joined: 4-September 04
Member No.: 228


Change: "It is good coding style to define the type attribute for all form fields" to "It is good coding style to define the type attribute for all form fields anyways"

You absolutely need to define the attribute in order the CSS2 attrribute matching to work.
Go to the top of the page
 
+Quote Post
Houdini
post Nov 16 2005, 10:03 PM
Post #9


Super Member
Group Icon

Group: Members
Posts: 572
Joined: 25-April 05
From: Nashville Tennessee
Member No.: 4,340


QUOTE(vizskywalker @ Nov 15 2005, 08:42 PM)
There is one possible solution, although 1) i have never tested it, and 2) I don't know if it is valid CSS.

Try this:
CODE
input:text {
 width: 400px;
}


The alternative is to simply pecify width in the html tag without using css, or nest the input in a <style> tag.

~Viz
[right][snapback]60773[/snapback][/right]

Try this
CODE
<input type="text" style="width:400px" />
you can use a sty;e with most HTML elements such as the input, the above code will make a test box that is 400px wide and yes it is valid so embed the style into the tag you are concerned with when you told it input (width:400px then all input types took on that attribute, just use it in those input fields by whatever type you want to effect because you have text inputs, submit inputs, password input, checkbox inputs radio button inputs and so on, so you need to just put the style in those you want to make bigger.
Go to the top of the page
 
+Quote Post
vdhieu84
post Nov 17 2005, 02:56 PM
Post #10


Member [ Level 1 ]
Group Icon

Group: Members
Posts: 32
Joined: 25-October 05
Member No.: 9,279


QUOTE(Houdini @ Nov 16 2005, 05:03 PM)
Try this
CODE
<input type="text" style="width:400px" />
you can use a sty;e with most HTML elements such as the input, the above code will make a test box that is 400px wide and yes it is valid so embed the style into the tag you are concerned with when you told it input (width:400px then all input types took on that attribute, just use it in those input fields by whatever type you want to effect because you have text inputs, submit inputs, password input, checkbox inputs radio button inputs and so on, so you need to just put the style in those you want to make bigger.
[right][snapback]60889[/snapback][/right]

You didn't read my orginal post. I said that there must be no additional attribute put in HTML code. `style` here is an attribute, and yes, I can't use it. I searched the internet for the whole 3 days and read the CSS2 specification over and over again... and probably I have to admit that they don't support it (at least for now).
Go to the top of the page
 
+Quote Post

2 Pages V   1 2 >
Reply to this topicNew Topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts   5 Curt200518 259 11th November 2009 - 06:29 PM
Last post by: yordan
No New Posts 0 Swisoon 104 30th October 2009 - 02:18 PM
Last post by: Swisoon
No New Posts   6 szupie 2,768 30th October 2009 - 01:06 PM
Last post by: Quatrux
No New Posts   5 starscream 69 30th October 2009 - 07:31 AM
Last post by: starscream
No New Posts   14 Grafitti 3,078 26th October 2009 - 06:34 AM
Last post by: iG-Khalid Mehmood Awan
No New Posts   2 Miles 745 12th October 2009 - 12:49 PM
Last post by: iG-John Rivera
No New Posts   10 bob3695 8,271 12th October 2009 - 06:38 AM
Last post by: iG-Sewe Oyaya
No New Posts   9 Koel 3,076 12th October 2009 - 12:58 AM
Last post by: levimage
No New Posts   2 jedipi 3,408 8th October 2009 - 08:47 AM
Last post by: iG-Neville
No New Posts   8 kc8ual 2,582 5th October 2009 - 08:56 PM
Last post by: HannahI
No New Posts   12 bnbrown 3,221 1st October 2009 - 08:33 PM
Last post by: iG-delilah !
No New Posts   1 thanatos1 121 7th September 2009 - 06:52 PM
Last post by: Curt200518
No New Posts 13 OpaQue 5,761 29th August 2009 - 04:43 AM
Last post by: skedad
No New Posts   4 clovis 1,786 24th August 2009 - 09:17 AM
Last post by: iG-neetu
No New Posts   1 fanbob 158 7th August 2009 - 02:36 PM
Last post by: yordan


Web Hosting Powered by ComputingHost.com.