Element “align” is obsolete or non-standard: what should I use instead?

天大地大妈咪最大 提交于 2019-12-03 22:12:19

You should use text-align in CSS rather than using the obsolete html styling attributes.

td{
text-align:center;
}

That would be something like:

<td style="text-align: center;">

But it would be even better to move that style out of the html and put it in a separate style-sheet.

You did not explain your goal, but using CSS is more modern...

<td style="text-align: center;">

Using that within a stylesheet, rather than inline would be even better...

td {
    text-align: center;
}

Use CSS, not element attributes.

<td style="text-align: center;">

You can also place this in an external style sheet:

td {
    text-align: center;
}

use css styling:

text-align:center

but styling tables doesn't really work well on ie6, if you need it

You could try using <td style="text-align: center;">. However, table elements themselves are not really recommended, so it might be Visual Studio's way of trying to force you to use the <div> element.

Nathan Q

Maybe with CSS?

text-align:center

#1 search result on Google for replacing deprecated align="center".

For people like me looking for ways to center other elements (not just <td>) you may also need to add width: 100% to the style tag.

<h1 style="text-align: center;width: 100%">

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!