开发者

HTML: why button does not show up inside a div but it does within a table?

Disclaimer: I'm not a web designer expert... my sense of beauty doesn't go beyond printf's formats.

Why this displays a button

<div id="redirMsg">
    <table>
    <tr>
    <td><label id="redirMsgLabel" /></td>
    </tr>
    <tr>
    <td><button onclick="Redirect()">Redirect</button></td>
    </tr>
  开发者_开发知识库  </table>
</div>

but this doesn't?

<div id="redirMsg">
    <label id="redirMsgLabel" />
    <button onclick="Redirect()">Redirect</button>
</div>

(Tried only in IE9...)

Thanks!


All else being equal, the botton will show up in both cases.

I'll hazard a guess that you have some CSS applied to the label that hides the content, and that you are not serving the document as application/xhtml+xml so the label is missing its end tag and the button is inside it.

You shouldn't have a label anyway — a button keeps its label internally. If you do have one, then it should have a for attribute which matches the id attribute of the control to which it is associated.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜