Which one is correct about the format of width?


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
-1
mycwcgr
5/4/2009 8:17:00 AM
πŸ“ asp.net.client-side
πŸ“ƒ 24353 articles.
⭐ 2 followers.

πŸ’¬ 7 Replies
πŸ‘οΈβ€πŸ—¨οΈ 2513 Views



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.
-1
HeartattacK
5/4/2009 8:22:34 AM

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
-1
manojlev
5/4/2009 8:43:09 AM

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 :)"
-1
shashankgwl
5/4/2009 10:59:07 AM

 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.
-1
asifchouhan
5/4/2009 11:17:30 AM

 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
-1
Coool
5/4/2009 11:18:19 AM

I believe that Firefox requires the "px" part or it won't work.
NC...
 
-1
NC01
5/4/2009 11:42:10 AM

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.
-1
HeartattacK
5/5/2009 4:04:00 AM
Reply: