I have this HTML code:
<td align="center">
and I'm getting this error in Visual Studio 2008 from ReSharper:
"Element '
align
' is obsolete or nonstandard"
What is the replacement of this code to make it standard?
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.
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%">
来源:https://stackoverflow.com/questions/7108504/element-align-is-obsolete-or-non-standard-what-should-i-use-instead