Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 445
hotcoder Avatar asked Aug 18 '11 13:08

hotcoder


People also ask

Is align deprecated?

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.

Which property is used for aligning elements?

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.

How do I keep text aligned in HTML?

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.

Is align attribute is supported in HTML5?

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.


2 Answers

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

td{ text-align:center; } 
like image 160
Jamie Dixon Avatar answered Sep 19 '22 19:09

Jamie Dixon


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.

like image 20
jeroen Avatar answered Sep 20 '22 19:09

jeroen