You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何不使用CSS实现指定样式HTML表格 附参考截图与已有代码

无CSS实现目标表格的HTML解决方案

你原代码存在标签嵌套逻辑错误、属性拼写错误、未正确使用跨列属性的问题,以下是符合要求的可直接运行代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <table border="1" width="400" cellpadding="5">
        <!-- 第一行:Hello world 跨3列 -->
        <tr>
            <td colspan="3">Hello world</td>
        </tr>
        <!-- 第二行:三个单元格,首格内嵌2行3列的子表格 -->
        <tr>
            <td>
                <table border="2" width="100%" cellspacing="2">
                    <tr>
                        <td>A</td>
                        <td>A</td>
                        <td>A</td>
                    </tr>
                    <tr>
                        <td>E</td>
                        <td>F</td>
                        <td>G</td>
                    </tr>
                </table>
            </td>
            <td>Cell B</td>
            <td>Cell C</td>
        </tr>
        <!-- 第三行:Hi There 跨3列 -->
        <tr>
            <td colspan="3">Hi There</td>
        </tr>
    </table>
</body>
</html>

代码说明:

  • 全程使用HTML原生属性实现,没有引入任何CSS代码
  • 用colspan="3"实现顶部和底部单元格跨三列的效果,避免多余嵌套表格
  • 修正了cellspacing属性的拼写错误,通过原生属性控制表格边框、内边距和间距
  • 所有标签嵌套符合HTML语法规范,结构清晰

内容的提问来源于stack exchange,提问作者Omry Biton

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.27 06:24:04