相关疑难解决方法(0)

<th>文本对齐兼容性

在表标题中,th标记的默认文本对齐方式是居中.

请考虑以下代码:

<!DOCTYPE html>
<html>
    <head>
        <style type="text/css">
            body {
                background-color: aliceblue;
            }
            .default_grid {
                text-align: left;
                width: 600px;
                color: white;
            }
                .default_grid th {
                    /*  text-align: left;  */
                }
                .default_grid .first {
                    background-color: purple;
                }
                .default_grid .second {
                    background-color: orange;
                }
        </style>
    </head>
    <body>
        <table class="default_grid">
            <thead>
                <tr>
                    <th class="first">Test One</th>
                    <th class="second">Test Two</th>
                </tr>
            </thead>
        </table>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

在Firefox,Internet Explorer 7(及更低版本),Safari,Chrome和Opera中,<th>中的文本左对齐.在Internet Explorer 8Internet Explorer 9中,除非直接在<th>标记上指定规则(取消注释第14行),否则文本将对齐居中.

哪一个是正确的行为?

html css html5 html-table

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

css ×1

html ×1

html-table ×1

html5 ×1