Nov 21, 2009
Pages: 1, 2

Css For Input Text Only - I don't think there is a solution but...

free web hosting

Read Latest Entries..: (Post #17) by iGuest on Oct 29 2009, 07:44 PM.
To specify an element with only certain attributes set, use this:   exampletag[exampleattrib="examplevalue"] For example, a paragraph with the height set to 300 will have a red background:  p[height="300"] { background: #ff0000; }  <p height="300">This should have a red background.</p> Hope I helped :)...
read more.
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Open Discussion & Free Web Hosting > Computers & Tech > Designing > Web Design and HTML

Css For Input Text Only - I don't think there is a solution but...

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

Comment/Reply (w/o sign-up)

clagnol
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?

Comment/Reply (w/o sign-up)

abhiram
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?

Comment/Reply (w/o sign-up)

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

Comment/Reply (w/o sign-up)

vizskywalker
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

Comment/Reply (w/o sign-up)

Retaining
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

Comment/Reply (w/o sign-up)

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

 

 

 


Comment/Reply (w/o sign-up)

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

Comment/Reply (w/o sign-up)

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

Comment/Reply (w/o sign-up)

vdhieu84
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).

Comment/Reply (w/o sign-up)

Latest Entries

iGuest

To specify an element with only certain attributes set, use this:

  exampletag[exampleattrib="examplevalue"]

For example, a paragraph with the height set to 300 will have a red background:

 p[height="300"] { background: #ff0000; }

 <p height="300">This should have a red background.</p>

Hope I helped :)


Comment/Reply (w/o sign-up)

TavoxPeru
QUOTE(FeedBacker @ Oct 16 2007, 09:13 AM) *
There are two ways to do this. The first is the 'proper' syntax - the second requires a new class:

<STYLE type="text/css">

input[type=text] {
width: 300px;
background-color: cyan;
}

input.text {
width: 300px;
background-color: yellow;
}

</STYLE>

<FORM>
<input type="text"><br>
<input class="text" type="text"><br>
<input type="text"><br>
<input type="submit">
</FORM>

Excellent info thanks, what about styling the button of the FILE input field??? is there a way to change for example the color and background color of this input field???

Best regards,

Comment/Reply (w/o sign-up)

iGuest
There are two ways to do this. The first is the 'proper' syntax - the second requires a new class:

<STYLE type="text/css">

input[type=text] {
width: 300px;
background-color: cyan;
}

input.text {
width: 300px;
background-color: yellow;
}

</STYLE>

<FORM>
<input type="text"><br>
<input class="text" type="text"><br>
<input type="text"><br>
<input type="submit">
</FORM>

Comment/Reply (w/o sign-up)

mastercomputers
I'm just wondering why you're not using the width attribute in that element which isn't deprecated, it will be when XForms takes over HTML Forms though.

What your problem really seems to be though is the lack of standard support, although, using input { width: 400px; } will affect most input elements, where as input[type=text] would be more suited to what you want but the lack of support is the downfall.

The textarea solution seems alright, is it avoiding newline characters? Would it require javascript to take the event of the keypress if it's allowed to submit the default form button?


Cheers,


MC

Comment/Reply (w/o sign-up)

Khymnon
A brilliant idea, twitch. Absolutely brilliant. Two thumbs-up for that one.

Actually, as far as IE7 and Microsoft in general are concerned, they don't worry so much about compliance with the W3C standards, including CSS. I haven't read anything about CSS support in IE7, but I wouldn't count on it too much. Plus, basic tests show that this bad boy is going to be devilishly vicious on system resources, so I don't suppose many will use it until Microsoft works it out.

If you absolutely can't use attributes, then I believe there isn't a way to do what you want, except for going with twitch's idea.

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Pages: 1, 2
Similar Topics

Keywords : css, input, text, solution

  1. Help With Making A Textbased Game
    im new to text based games (2)
  2. Animated Favicon With Scrolling Text!
    Free Animated FavIcon With Scrolling Text! (13)
    Anybody needs Animated FavIcon with your site address scrolling on that along with your logo?
    Check this site! Thats the site without any customization Options! But if you need to customize
    the Animated Icon, please reply here (In the sense, Fonts & Color Customization) Im doing it
    for Free! Example is here: checkOut the fav icon for: www.niranvv.com and
    www.fun.niranvv.com You can see one Icon along with one Scrooling Text: NiranVv.Com in the
    icon! So, if you need that one, ask here! I'll give you the animated favIcon(Gif Format) ....
  3. Get Input From Html/txt File?
    with just html/css and maybe javascript? (2)
    I was just wondering if it's possible to retrieve text (and maybe images) from a .html or .txt
    file. So for example you get the header and footer from an external file. Is it possible with just
    html/css and maybe a little javascript or does it require server side scripting like php???
    -=jeroen=-....
  4. Hiding/showing Text On Click
    is it possible with css/javascript (2)
    Ok, I got an question: I want to make a site with a news box or something similar. It's gonna be
    a table with a small piece of text and an "read more" button. Now I want to make it so that if
    people click on the "read more" there will appear an other piece of text underneath it. How do I do
    this? thanks in advance, -=jeroen=-....
  5. Xhtml Is Not Suppose To Be Text/html
    IE not planning to support XHTML yet (8)
    I am quite disappointed in IE's development as with keeping up but still if they feel they need
    to fully work on current things that they have already attempted to resolve and perfect then that is
    a good thing, but development should have never got so messy and only the developer would know that
    it's his fault and not MS's. This isn't to bad mouth IE, but it's so sad to know
    that even after 5 years or more of IE6, IE7 has no intention of supporting XHTML and I don't
    think I can wait for IE8 if development takes such a long time. They should also....
  6. Html: Alt Text For Objects
    Is it possible? (8)
    My site is going to use a lot of Flash files pluged into the page. I embed it into the page like
    this: CODE What I want to know is: Is it possible to give the object an alt text?
    Something like the alt="The Flash File" that is used in IMG tags is what I want. I've tried
    putting it inside the object tag, param tag and embed tag. That didn't work.....
  7. Wrap
    I am trying to wrap text after a textbox (2)
    I am trying to wrap text after a textbox. It is working fine on IE. but it doesn't work on
    Netscape 7.0 and Firefox 1.0.1 /huh.gif" style="vertical-align:middle" emoid=":huh:" border="0"
    alt="huh.gif" /> Following is the code: CODE Airport/city
    name or 3 letter code. The "Airport/city name or 3 letter code. " text waps
    around in IE by not in NN or firefox. Do somebody tell me how to do it? Notice
    from m^e: Please put your code between CODE tags from next time onwards. That ....
  8. Game Website
    text base (4)
    I want to make a online game website, can I do with astohost? I been trying to get a free website
    but it's seems to harder then I thought, I hope this one work, everytime I apply they never send
    a confirmation email. Will the site I get from astohost be able to do what I want, a text base game
    with some animation, like flash, I need help so if anyone can help let me know.....
  9. Good Text Html Editor
    (24)
    Does someone know good text HTML editor for web page creation?(sure, I mean text editor, not
    WYSWYG). There is no reason to stick with Notepad when there is a set of the various special html
    editors much more convenient than ms Notepad. No any of microsoft products does not not suit for
    html editing, and Frontpage is absolute rotten.....
  10. wut is html?
    hyper text (4)
    wut is html? well html is a kind of languge i think and it is used to make website? i think thats
    html is one of thy best website making languges....
  11. Text-Based HTML Editors
    (5)
    1st Page 2000 1st Page 2000 is the tool that lets you create powerful, great looking websites
    fast, easier and on-time. AceExpert In addition to being an excellent HTML editor, AceExpert
    also greatly assists you with predefined Java applets and JavaScripts. AceExpert is the solution for
    developers who want to integrate the latest technologies into their Web pages. Simple and easy to
    use, AceExpert gives you the full power of a complete HTML Editor. Arachnophilia Arachnophilia
    lets you use two methods to create Web pages: The 'old-fashioned way' with th....

    1. Looking for css, input, text, solution

See Also,

*SIMILAR VIDEOS*
Searching Video's for css, input, text, solution
advertisement



Css For Input Text Only - I don't think there is a solution but...

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com