W HTML5, w odniesieniu do tabel, co zastępuje cellpadding, cellspacing, valign i align?

W Visual Studio widzę te ostrzeżenia:

  • Walidacja (HTML 5): atrybut ' cellpadding 'nie jest prawidłowym atrybutem elementu'table'.
  • Walidacja (HTML 5): atrybut 'cellspacing' nie jest poprawnym atrybutem elementu 'table'.
  • Walidacja (HTML 5): atrybut 'valign' nie jest poprawnym atrybutem elementu 'td'.
  • Walidacja (HTML 5): atrybut 'align' nie jest poprawnym atrybutem elementu 'td'.

Jeśli nie są poprawnymi atrybutami w HTML5, co je zastępuje w CSS?

Author: Brian Tompsett - 汤莱恩, 2011-05-18

5 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; }
 449
Author: drudge,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-01-19 21:27:45

To powinno rozwiązać twój problem:

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;
}
 69
Author: Cole Johnson,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-11-18 07:09:21

Na konkretnym stole

<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>
 12
Author: Xtian11,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-04-30 16:29:47

Alternatywnie można użyć dla konkretnej tabeli

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

Dodaj ten css do zewnętrznego pliku

.tableFormatter
{
width:100%;
vertical-align:top;
text-align:center;
}
 3
Author: JaiSankarN,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-12-29 10:13:09

Myślę, że używasz Visual Studio do edycji strony internetowej. Wtedy też stanąłem przed tym samym problemem. Rzecz w tym, że nie ma takiego "atrybutu" dla tego elementu.

Musisz przenieść ten atrybut do style:

From:

<td valign="top">XXXX</td>

Do:

<td style="vertical-align:top;">XXXX</td>
 0
Author: Xin,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-04-18 05:27:22