Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of setting width equal to an asterisk in inline styles?

Tags:

html

css

So, maybe this is a typo but I came across some old code:

<td valign="top" width="*">

Was this a typo? or does this do something special?

like image 853
Doug Chamberlain Avatar asked Dec 01 '11 21:12

Doug Chamberlain


2 Answers

This allows means "remaining space". You can use several in conjunction. e.g..

<td valign="top" width="*">...</td><td valign="top" width="2*">...</td>

Together, these two columns will use all the horizontal space available. The second will be twice as wide as the first.

Update:

To respond to the comment made below, I found the following on the W3 site:

Proportional specifications (e.g., width="3*") refer to portions of the horizontal space required by a table. If the table width is given a fixed value via the width attribute of the TABLE element, user agents may render the table incrementally even with proportional columns.

However, if the table does not have a fixed width, user agents must receive all table data before they can determine the horizontal space required by the table. Only then may this space be allotted to proportional columns.

Source: http://www.w3.org/TR/html4/struct/tables.html

like image 84
tarmes Avatar answered Sep 27 '22 23:09

tarmes


"*" is MultiLength value defined in HTML. See: http://www.w3.org/TR/html4/types.html#h-6.6

like image 36
c-smile Avatar answered Sep 27 '22 23:09

c-smile