Define the size in pixels of a textarea? (form)

  • WritingBadCode
  • Graduate
  • Graduate
  • User avatar
  • Posts: 214
  • Loc: Sweden

Post 3+ Months Ago

Basically what I want to do is make a form that is "exactly" 200 px wide so it will fit perfectly in a DIV I have. I know I can define the size somewhat precise with rows and cols but its clumsy and that's not what I want, is there a way to do this using CSS or something?

:|
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

Yes. Use a "style" attribute and define your width inside that style attribute just like you would in a stylesheet.

The style attribute works just like the rows and columns attributes. You can think of the style attribute like a place where you can apply CSS stylesheet rules directly to an element.

HTML Code: [ Select ]
<textarea style="width:200px;"></textarea>


The style attribute is valid for pretty much any element you'll ever have in your pages. You can even apply it directly to your <form> element.

Now, depending on what styles you have in your stylesheets already, for instance whether or not you're using a "CSS Reset", you might need to zero out the margin and padding on your element as well in order to get exactly 200 pixels.

HTML Code: [ Select ]
<textarea style="width:200px; margin:0; padding:0;"></textarea>
  • WritingBadCode
  • Graduate
  • Graduate
  • User avatar
  • Posts: 214
  • Loc: Sweden

Post 3+ Months Ago

joebert wrote:
Yes. Use a "style" attribute and define your width inside that style attribute just like you would in a stylesheet.

The style attribute works just like the rows and columns attributes. You can think of the style attribute like a place where you can apply CSS stylesheet rules directly to an element.

HTML Code: [ Select ]
<textarea style="width:200px;"></textarea>


The style attribute is valid for pretty much any element you'll ever have in your pages. You can even apply it directly to your <form> element.

Now, depending on what styles you have in your stylesheets already, for instance whether or not you're using a "CSS Reset", you might need to zero out the margin and padding on your element as well in order to get exactly 200 pixels.

HTML Code: [ Select ]
<textarea style="width:200px; margin:0; padding:0;"></textarea>



I tried your suggestion and it does what I want. : ) Problem solved!

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 30 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.