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

前端 未结 3 1602
甜味超标
甜味超标 2020-12-17 18:42

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


Was this a typo? or does this do something

相关标签:
3条回答
  • 2020-12-17 19:24

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

    0 讨论(0)
  • 2020-12-17 19:24

    That's not "inline style", but legacy HTML that should be avoided in favor of CSS. But, to answer your question, it means, essentially, "fill". But, in practice it has no effect and can be safely removed.

    http://jsfiddle.net/sn4qn/5/

    Perhaps it's there as an indicator to future developers that the width was intended to be set automatically by the browser.

    0 讨论(0)
  • 2020-12-17 19:35

    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

    0 讨论(0)
提交回复
热议问题