I find sometimes display Width="30" and sometimes dispaly Width="30px" in the editor of VS 2008, but no error occurs on the two formats
but Which one is the correct format of width?
<asp:TextBox ID="TextBox1" runat="server" Width="30"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" Width="30px"></asp:TextBox>
SuperCool Multiple ZIP - A utility to unzip multiple files and work with multiple zip files
SuperCool Random Number Generator
![]() |
0 |
![]() |
They both produce the same html. If you don't mention a unit, px is used. So in the output html, you'll see 30px in both cases.
All that glitters is gold-
Only shooting stars break the mold.
![]() |
0 |
![]() |
Hi,
Actually both are working as same.
By default Tabels width take values in pixels
if you not specifying the unit as px
e.g. if you specify width = "10" or width="10px" both are correct way.
its better to put widht in percentage like width = "10%" its compatible
to all browsers.I hope this may help you.
Thank You
Manoj Chavan
-------------------------------------------
Web Application Developer(C#.NET, ASP.NET, C++.NET)
My Blog
Always think high, Always Dream High.
If this post helps you then plz Mark It as Answer
![]() |
0 |
![]() |
All i can tell you is that HTML is so loose a language that even if you write
<input type="text" width="10px" innerPassword="hello"/> , still you'll see the nice textbox on your page.
SHASHANK BHIDE
CAPGEMINI INDIA
"THE ROAD TO SUCCESS IS ALWAYS UNDER CONSTRUCTION MARK MY RESPONSE AS ANSWER TO HELP ME BUILD IT :)"
![]() |
0 |
![]() |
Bydefault the width or height is in pixel format so you specify it or not, it is not mandatory
if you just change px to cm, see the changes and if you remove cm it is bydefault in pixel, This means for any other Unit of Measure you have specify the type. cm,inch or etc
<asp:TextBox ID="TextBox2" runat="server" Width="30cm"></asp:TextBox>
Regards
Asif
Please remember to click “Mark as Answer” on the post that helps you.
This can be beneficial to other community members reading the thread.
![]() |
0 |
![]() |
Hi mycwcqr,
For better understanding of measurement units please refer to the following article.
http://css.weblogsinc.com/2005/02/17/the-difference-between-px-pt-and-em/
Please mark as Answer if it helps u. Thanks!
Parth Patel
Techsture Technologies
Software Developer
Ahmedabad
![]() |
0 |
![]() |
I believe that Firefox requires the "px" part or it won't work.
NC...
![]() |
0 |
![]() |
Actually NC, if you put Width='100' for a server side control, asp.net automatically converts it to width='100px' in the output html. As a result, it'll work on FF too. Of course, it has to be a server side control for the conversion to work.
All that glitters is gold-
Only shooting stars break the mold.
![]() |
0 |
![]() |