Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML 'td' width and height

The 'height' and 'width' are not supported in HTML5. How can I set a td's width and height while conforming to the HTML5 standard?

<!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> 
like image 570
Shane Hsu Avatar asked Oct 14 '12 09:10

Shane Hsu


People also ask

How set width and height in HTML TD?

To set the cell width and height, use the CSS style. The height and width attribute of the <td> cell isn't supported in HTML5. Use the CSS property width and height to set the width and height of the cell respectively.

What is td height in HTML?

< td height = "100" >EC</ td > </ tr > </ table > </ body > </ html >

How do I fix TD size in HTML?

By using CSS, the styling of HTML elements is easy to modify. To fix the width of td tag the nth-child CSS is used to set the property of specific columns(determined by the value of n) in each row of the table.


2 Answers

The width attribute of <td> is deprecated in HTML 5.

Use CSS. e.g.

 <td style="width:100px"> 

in detail, like this:

<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> 
like image 175
Ravindra Bagale Avatar answered Sep 25 '22 03:09

Ravindra Bagale


Following width worked well 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> 

Please note that

  • TD tag is without CSS style.
like image 30
Sukumar Avatar answered Sep 25 '22 03:09

Sukumar