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?
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.
Answer: Use the CSS padding & border-spacing property This is a valid way to produce the same effect as table's cellpadding attribute.
The cell padding attribute places spacing around data within each cell. The cell spacing attribute places space around each cell in the table.
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.
/* 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; }
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