Using CSS height and width for <textarea>

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bugboy
    New Member
    • Sep 2007
    • 160

    Using CSS height and width for <textarea>

    Is it ok to use CSS height: and width: attributes instead of rows and cols to size a textarea? It seems to work but i think i remember reading somewhere that i shouldn't do it...Is there any good reason to avoid it?

    Thanks in advance!
    Bugboy
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Originally posted by bugboy
    Is it ok to use CSS height: and width: attributes instead of rows and cols to size a textarea? It seems to work but i think i remember reading somewhere that i shouldn't do it...Is there any good reason to avoid it?

    Thanks in advance!
    Bugboy
    I can't think of any good reason not to; you have more control if you size the element using pixels, as opposed to columns and rows.

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      Hi.

      The "cols" and "rows" attributes are required for the <textarea> element.
      If you omit them your HTML will be invalid.
      (See http://www.w3.org/TR/html401/interact/forms.html#h-17.7)

      It's best to just do both. Add the attributes and apply the CSS styles.
      Most browsers will prefer the CSS styles and simply ignore the attributes, but they will be there to fall back on if the CSS (for some reason) doesn't work,

      Comment

      • bugboy
        New Member
        • Sep 2007
        • 160

        #4
        Thanks guys!

        Regards

        bugboy

        Comment

        Working...