Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jan 2011
    Posts
    136
    Thanks
    101
    Thanked 0 Times in 0 Posts

    text and textarea width vary between different browsers

    I am using both text and textarea in my forms. My goal is to make their width the same.

    Currently, I am using these

    Code:
    <input type="text" name=xx size="100"/>
    Code:
    <textarea name=yy cols="75" rows="10">$Eabstract$</textarea>
    The problem is that the width of the text box and textarea will show up differently in different browsers. For example, the current setting works great in Firefox. But the textarea will appear narrower in the IE. If I increase the cols of the textarea, it will appear wider than the text in the Firefox.

    What should I do?

    Is there a way I can set their width as pixels instead?
    Last edited by camaross; 04-24-2011 at 03:09 PM.

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by camaross View Post
    I am using both text and textarea in my forms. My goal is to make their width the same.

    Currently, I am using these

    Code:
    <input type="text" name=xx size="100"/>
    Code:
    <textarea name=yy cols="75" rows="10">$Eabstract$</textarea>
    The problem is that the width of the text box and textarea will show up differently in different browsers. For example, the current setting works great in Firefox. But the textarea will appear narrower in the IE. If I increase the cols of the textarea, it will appear wider than the text in the Firefox.

    What should I do?

    Is there a way I can set their width as pixels instead?
    in a css file try:
    Code:
    textarea, input { width: 400px; }
    or
    Code:
    textarea[name='yy'] { width: 400px; }
    input[name='xx'] { width: 400px; }
    since markup is invalid is possible to not work as you expect.

    best regards

  • Users who have thanked oesxyl for this post:

    camaross (04-25-2011)

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Is there a way I can set their width as pixels instead?
    Code:
    <input type="text" name="xx" class="text"/>
    Code:
    input.text{
    width:100px;
    }
    and similarly for textarea.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    camaross (04-25-2011)

  • #4
    Regular Coder
    Join Date
    Jan 2011
    Posts
    136
    Thanks
    101
    Thanked 0 Times in 0 Posts
    Thank you very much, guys.

  • #5
    New Coder
    Join Date
    Apr 2011
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try the following code:

    <input type="text" name="xx" style="width:100px;" />

    <textarea name="yy" style="width:100px;">$Eabstract$</textarea>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •