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?
As noted earlier, HTML 4 deprecated the align attribute, which was previously used to align text, tables, cell contents, other objects, and position captions. CSS replaces this with the text-align property for text.
The text-align property in CSS is used to specify the horizontal alignment of text in an element ie., it is used to set the alignment of the content horizontally, inside a block element or table-cell box. Property Value: left: It is used to set the text-alignment into left.
To set text alignment in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property text-align for the center, left and right alignment.
The align attribute of <object> is not supported in HTML5. Use CSS instead. For an object to align middle, top, or bottom use the CSS property vertical-align. For an object to align left or right use the CSS property float.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With