2012-10-14 13 views
36

"height" e "width" non sono supportati in HTML5. Come posso impostare la larghezza e l'altezza di un td rispettando lo standard HTML5?HTML "td" width and height

<!DOCTYPE html> 
<html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <title>219 班網</title> 
    </head> 

    <body bgcolor="silver"> 
    <div align="center"> 
     <table> 
     <tr> 
      <td width="1000" height="250"> 
      <object width="100%" height="100%" data="frameTop.html"></object> 
      </td> 
     </tr> 
     </table> 
     <table> 
     <tr> 
      <td width="300" height="700" > 
      <object width="100%" height="100%" data="frameLeft.html"></object> 
      </td> 
      <td width="700" height="700"> 
      <object width="100%" height="100%" data="frameRight.html"></object> 
      </td> 
     </tr> 
     </table> 
    </div> 
    </body> 
</html> 
+0

Per eventuali HTML/JavaScript persone che il codice è nel layout in stile C LOL –

+0

Si dovrebbe usare i CSS – Zyga

+0

@Zyga Quindi, se io uso CSS per assegnare larghezza e l'altezza del valore, non sarà in conflitto con HTNL5 standard? –

risposta

63

L'attributo larghezza <td> è deprecato in HTML 5.

Usa CSS. ad es.

<td style="width:100px"> 

in dettaglio, in questo modo:

<table > 
    <tr> 
    <th>Month</th> 
    <th>Savings</th> 
    </tr> 
    <tr> 
    <td style="width:70%">January</td> 
    <td style="width:30%">$100</td> 
    </tr> 
    <tr> 
    <td>February</td> 
    <td>$80</td> 
    </tr> 
</table> 
+0

Grazie! Capito! –

+0

Cosa succede se è necessario superare la larghezza della pagina? Ad esempio la larghezza della pagina è 2000 e la tua cella deve essere 5000 come: Gennaio –

+0

@IgorKrupitsky metti la tabella dentro t div che ha css: overflow-x: scroll ; Si otterrà quindi una barra di scorrimento orizzontale – punkologist

1

seguito width funzionato bene in HTML5: -

<table > 
    <tr> 
    <th style="min-width:120px">Month</th> 
    <th style="min-width:60px">Savings</th> 
    </tr> 
    <tr> 
    <td>January</td> 
    <td>$100</td> 
    </tr> 
    <tr> 
    <td>February</td> 
    <td>$80</td> 
    </tr> 
</table> 

prega di notare che

  • tag TD è senza CSS stile.
Problemi correlati