Html 没有css的表格格式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5862201/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 08:22:51  来源:igfitidea点击:

table formatting without css

htmlcss

提问by user544079

I have a table defined as

我有一个表定义为

<table border="1" width="200px" height="auto">
<tr>
<td></td>
</tr>
</table>

Is there a way that I can align the table at the center of the page, apply background color to page without using css for any of these operations?

有没有一种方法可以让我在页面中心对齐表格,将背景颜色应用于页面而不使用 css 进行任何这些操作?

回答by Phrogz

I assume you are doing something horrible like HTML email:

我假设你正在做一些可怕的事情,比如 HTML 电子邮件:

<center><table bgcolor="#ff00ff"></table></center>

回答by morewry

<center>
    <table border="1" cellspacing="0" cellpadding="0" width="200" align="center">
        <tr>
            <td background="http://www.yourdomain.com/email/images/background.jpg" align="left">
            <!-- Stuff -->
            </td>
        </tr>
    </table>
</center>

The background attribute was never valid on table or td. Pretty sure the only thing the HTML 4 specification had background on was body. But I vaguely recall that it worked elsewhere and I think table cells was elsewhere--whether it works in Outlook you'll just have to test. bgcolor was valid all of those places...and is likely to work.

background 属性在 table 或 td 上永远无效。可以肯定的是,HTML 4 规范唯一的背景就是正文。但我依稀记得它在其他地方工作,我认为表格单元格在其他地方——它是否在 Outlook 中工作,你只需要测试。bgcolor 在所有这些地方都是有效的……而且很可能会起作用。