开发者

Table cell sizing in quirk mode

In Firefox 4 and Chrome (unverified in other browsers), the table cell has a small black border on the bottom with <!DOCTYPE html> (i.e. html5 mode). Take it out (i.e. quirk mode) and the border disappears. I was wondering how can I have the border-less version in html5 mode. Am I missing something in the stylesheet?

With small, unintentional border on bottom when rendering with <!DOCTYPE html>

Table cell sizing in quirk mode

Without border on bottom when rendering without <!DOCTYPE html>

Table cell sizing in quirk mode

Thanks

<!DOCTYPE html>
<html>
  <head>
    <style>
      table.icon {
        display: inline-table;
        border-collapse: collapse;
        border-spacing: 0px;
        text-align: center;
        vertical-align: middle;
        padding: 0px;
        margin: 2px 0px;
        border: hidden;
      }

      table.icon td.content {
        vertical-align: middle;
        background-color: black;
        width: 100px;
        height: 100px;
        padding: 0px;
        margin: 0px 0px;
        border: hidden;
      }

      .block {
        width:50px;
        height:100px;
        background-color: green;
      }
    </style>
  </head>
  <body>
    <table class="icon"&开发者_StackOverflow社区gt;
      <tr>
        <td class="content"><img class="block"></td>
      </tr>
    </table>
  </body>
</html>


I see no difference, but:

  1. icons should not be img elements, they should be background images
  2. a table with one cell is not a table at all
  3. if you want a border on the bottom of something (or even want to remove the same), use the border-bottom property
  4. regardless of the differences, you always want a properly included doctype declaration (how you're doing it here is fine)
  5. the type="text/css" attribute on style elements is unnecessary in HTML5
  6. while not invalid in HTML5, closing img elements in HTML is still goofy unless you require your code to have XML conformity
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜