Welcome Guest ( Log In | Register )



2 Pages V   1 2 >  
Reply to this topicStart new 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.

Notice from vizskywalker:
Edited on user's Request, next time, report the post instead of making another one though
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.
*




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
*


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.
*


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 topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Good Text Html Editor(24)
  2. Game Website(4)
  3. Wrap(2)
  4. Html: Alt Text For Objects(8)
  5. Xhtml Is Not Suppose To Be Text/html(8)
  6. Hiding/showing Text On Click(2)
  7. Get Input From Html/txt File?(2)
  8. Animated Favicon With Scrolling Text!(12)
  9. Help With Making A Textbased Game(2)


 



- Lo-Fi Version Time is now: 30th August 2008 - 04:07 AM