Wat vervangt cellpadding, cellspacing, valign, en align in HTML5 tabellen?

Visual Studio , ik zie deze waarschuwingen:

  • Validation (HTML 5) aan. ‘ ‘Cellpadding’ is geen geldig attribuut van element ‘table’
  • Validation (HTML 5) aan. ‘ ‘Cellspacing’ is geen geldig attribuut van element ‘table’
  • Validation (HTML 5) aan. ‘ ‘Valign’ is geen geldig attribuut van element ‘td’
  • Validation (HTML 5) aan. ‘ ‘Align’ is geen geldig attribuut van element ‘td’

Als ze niet geldig zijn attributen in HTML5 , wat daarvoor in de plaats in CSS?


Antwoord 1, Autoriteit 100%

/* 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; }

Antwoord 2, Autoriteit 14%

Dit zou het probleem op te lossen:

td {
    /* <http://www.w3.org/wiki/CSS/Properties/text-align>
     * left, right, center, justify, inherit
     */
    text-align: center;
    /* <http://www.w3.org/wiki/CSS/Properties/vertical-align>
     * baseline, sub, super, top, text-top, middle,
     * bottom, text-bottom, length, or a value in percentage
     */
    vertical-align: top;
}

Antwoord 3, Autoriteit 3%

Aan bepaalde tabel

<table style="border-collapse: separate; border-spacing: 10px;" >
    <tr>
      <td>Hi</td>
      <td>Hello</td>
    <tr/>
    <tr>
      <td>Hola</td>
      <td>Oi!</td>
    <tr/>
</table>

Antwoord 4

Kan ook voor een bepaalde tafel gebruiken

<table style="width:1000px; height:100px;">
    <tr>
        <td align="center" valign="top">Text</td> //Remove it
        <td class="tableFormatter">Text></td>
    </tr>
</table>

Voeg deze css toe aan extern bestand

.tableFormatter
{
width:100%;
vertical-align:top;
text-align:center;
}

Other episodes