Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing over from Size="xx" to Width="XXpx"

Status
Not open for further replies.

DLLHell

Programmer
May 9, 2003
69
US
Is there an easy way/algorithm to convert old HTML's Size="XX" (# of characters) to new HTML's WIDTH="XXpx" (pixels)? Is it all trial & error/hit & miss till you get a matching comparision?

I get a compiler warning when using SIZE but it still allows it for datagrids. I got burnt using Size and have to go to Width/pixels as a grid column could either be a textbox-type or a label type and its Header column has to be sized depending on the type of column. There is no "Size" property to use... only the "Width" property exists.

Why'd they get rid of Size anyway? It was a lot easier...



 
I would have thought that:

Code:
<input type=&quot;text&quot; size=&quot;5&quot;>

would have been the same as:

Code:
<input type=&quot;text&quot; style=&quot;width:5em;&quot;>

Although it's not ;o(

As 1em is the width of 1 'm' in whatever font style you are using, it's a good approximation, however, that if you use &quot;width:Xem;&quot; then you'll definately be able to fit X characters in your input box.

Hope this helps!

Dan
 
&quot;I get a compiler warning when using SIZE...&quot;

What are you compiling?

&quot;...but it still allows it for datagrids.&quot;

What's a datagrid? Do you mean a table? There's no size attribute in any of the table elements AFAIK, but it doesn't matter because the table will stretch to accommodate whatever elements are within it.

Post some code or (preferably) a URL so we can see what's going wrong.

Oh, and they didn't get rid of size - it's still a valid attribute for <input> in all versions of (X)HTML.

-- Chris Hunt
 
Billy, thanks.

Chris, thanks.

I guess the ASP.NET compiler gave a warning about using SIZE in an ASP.NET Datagrid which is not 100% pure HTML, but it still allowed the use of it.

I got around the problem by just converting all SIZE to Pixel the trial & error way which I had to do anyway in order to use .NET's MeasureString function to compute the size of Table cells (via .NET web control, not real HTML) based on the font & text. I think the trouble is that CSS does not support SIZE but only pixels/pct & .em (?).

I was told that there were HTML editors where pixels/pct/size/em could be changed by the editor but I have not seen one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top