在Visual Studio中,我看到了这些警告:
- 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’.
如果他们不是HTML5中的有效属性,什么替换他们在CSS?
解决方法
/* 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; }