Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What replaces cellpadding, cellspacing, valign, and align in HTML5 tables?

In Visual Studio, I'm seeing these warnings:

  • Validation (HTML 5): Attribute 'cellpadding' is not a valid attribute of element 'table'.
  • Validation (HTML 5): Attribute 'cellspacing' is not a valid attribute of element 'table'.
  • Validation (HTML 5): Attribute 'valign' is not a valid attribute of element 'td'.
  • Validation (HTML 5): Attribute 'align' is not a valid attribute of element 'td'.

If they are not valid attributes in HTML5, what replaces them in CSS?

like image 624
Code Maverick Avatar asked May 18 '11 17:05

Code Maverick


People also ask

What can I use instead of cellpadding in HTML5?

HTML5 do not support the cellpadding attribute of <table>, so the CSS property padding is used with the style attribute to set cell padding. Just keep in mind, the usage of style attribute overrides any style set globally. It will override any style set in the HTML <style> tag or external style sheet.

What can I use instead of cellpadding?

Answer: Use the CSS padding & border-spacing property This is a valid way to produce the same effect as table's cellpadding attribute.

What is cellpadding and Cellspacing in table?

The cell padding attribute places spacing around data within each cell. The cell spacing attribute places space around each cell in the table.

Why do we use cellpadding and Cellspacing with table tag?

Cellpadding specifies the space between the border of a table cell and its contents (i.e) it defines the whitespace between the cell edge and the content of the cell. Cellspacing: Cellspacing specifies the space between cells (i.e) it defines the whitespace between the edges of the adjacent cells.


1 Answers

/* cellpadding */ th, td { padding: 5px; }  /* cellspacing */ table { border-collapse: separate; border-spacing: 5px; } /* cellspacing="5" */ table { border-collapse: collapse; border-spacing: 0; }   /* cellspacing="0" */  /* valign */ th, td { vertical-align: top; }  /* align (center) */ table { margin: 0 auto; } 
like image 147
drudge Avatar answered Oct 02 '22 19:10

drudge