En HTML5, con respecto a las tablas, ¿qué reemplaza cellpadding, cellspacing, valign y align?


En Visual Studio , estoy viendo estas advertencias:

  • Validación (HTML 5): El atributo 'cellpadding' no es un atributo válido del elemento 'table'.
  • Validación (HTML 5): El atributo 'cellspacing' no es un atributo válido del elemento 'table'.
  • Validación (HTML 5): El atributo 'valign' no es un atributo válido del elemento 'td'.
  • Validación (HTML 5): El atributo 'align' no es un atributo válido del elemento 'td'.

Si no son atributos válidos en HTML5 , ¿qué los reemplaza en 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/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-01-19 21:27:45

Esto debería resolver tu problema:

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/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-11-18 07:09:21

En un cuadro particular

<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/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-04-30 16:29:47

Alternativamente, puede utilizar para la tabla particular

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

Añadir este css en el archivo externo

.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/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-12-29 10:13:09

Creo que está utilizando Visual Studio para editar la página web. Entonces también me enfrenté al mismo problema. La cosa es, no hay tal 'atributo' para este elemento.

Tienes que mover este atributo al estilo:

De:

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

A:

<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/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-04-18 05:27:22