开发者

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

开发者 https://www.devze.com 2023-02-28 22:36 出处:网络
Disclaimer: I\'m not a web designer expert... my sense of beauty doesn\'t go beyond printf\'s formats.

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

精彩评论

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

关注公众号