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?
Try using the code given below:
/* 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; }
Note : Just use border-collapse: collapse for your table, and padding for th or td . This style is for full reset for tables - cellpadding, cellspacing and borders. TBH. For all the fannying around with CSS you might as well just use cellpadding="0" cellspacing="0" since they are not deprecated