【问题标题】:Attribute (align) is obsolete. Its use is discouraged in HTML5 documents [duplicate]属性 (align) 已过时。不鼓励在 HTML5 文档中使用它 [重复]
【发布时间】:2017-03-21 16:09:21
【问题描述】:

我在使用 align 属性时遇到以下错误。 如何使用适当的 HTML5 兼容语法解决此错误?

<table  align="center">
            <tbody>
            <tr>
                <td><input type="text" name="username" placeholder="User Name" id="username" autocomplete="off"></td>
            </tr>
            <tr>
                <td><input type="password" name="password" placeholder="Password" id="password" autocomplete="off"></td>
            </tr>
            <tr>
                <td align="right">
                <input type="submit" class="btn btn-success" id="loginbutton" value="LOGIN" />
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                <input type="reset" class="btn btn-danger" id="resetbutton" value="RESET"/></td>
            </tr>
            </tbody>
        </table>

【问题讨论】:

  • 如果您完全搜索过这个,那就太棒了。 Here 是一个 5 年前的问题,告诉你如何解决它

标签: jquery css html jsp-tags


【解决方案1】:

我认为你应该 center 对齐 table 与关注

table
{ 
    margin-left: auto;
    margin-right: auto;
}

【讨论】:

  • style="text-align: center;"只是这很好用:)
【解决方案2】:

使用类而不是内联 css。

<style>
.p {
    align-self:center
}
</style>

<table  class="p">
</table>

【讨论】:

    【解决方案3】:

    align 属性在 HTML5 中已被弃用,您可以通过这种方式使用它,它会起作用,

    <td style="text-align:right">
    

    【讨论】:

    • align 没有被弃用,它已经过时了。 “过时”和“已弃用”是不同的东西。过时的属性在当前版本中可能根本不起作用,而弃用的属性仍然有效,但不受支持,并且可能在未来的版本中过时
    猜你喜欢
    • 1970-01-01
    • 2020-04-05
    • 1970-01-01
    • 2013-11-04
    • 1970-01-01
    • 2015-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多