- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set cell width and height in HTML?
We use the inline CSS style, to set the cell width and height.
The HTML style element contains width and height attributes. To set cell width and height we should place these attributes with specified values with pixels inside the <td> tag.
Syntax
Following is the syntax to set cell width and height in HTML.
<td style="width: 20px;height: 40px">content</td>
Example
Following is the example program to set cell width and height in HTML.
<!DOCTYPE html> <html> <style> table,tr,th,td { border:1px solid black; } </style> <body> <h2>Tables in HTML</h2> <table style="width: 100%"> <tr> <th >Name </th> <th>Job role</th> </tr> <tr> <td style="width: 20px;height: 40px">Tharun</td> <td >Content writer</td> </tr> <tr> <td>Akshaj</td> <td >Content writer</td> </tr> </table> </body> </html>
In above example we tried to set width and height of the first-row cells of the table.
Example
Following is the example program to set cell width and height in HTML.
<!DOCTYPE html> <html> <style> table,tr,th,td { border:1px solid black; } </style> <body> <h2>Tables in HTML</h2> <table style="width: 100%"> <tr> <th >Name </th> <th>Job role</th> </tr> <tr> <td style="width: 20px;height: 40px">Tharun</td> <td >Content writer</td> </tr> <tr> <td style="width: 20px;height: 40px" >Akshaj</td> <td >Content writer</td> </tr> </table> </body> </html>
In above example we tried to set width and height of the first all the rows cells of the table.
Example
Following is the example program to set cell width and height in HTML.
<!DOCTYPE html> <html> <style> table,tr,th,td { border:1px solid black; } </style> <body> <h2>Tables in HTML</h2> <table style="width: 100%"> <tr> <th>Name </th> <th>Job role</th> </tr> <tr> <td style="width: 20px;height: 40px">Tharun</td> <td style="width: 20px;height: 40px">Content writer</td> </tr> <tr> <td style="width: 20px;height: 40px" >Akshaj</td> <td style="width: 20px;height: 40px">Content writer</td> </tr> </table> </body> </html>
- Related Articles
- How to set viewport height and width in CSS
- How to use height and width attributes in HTML?
- How to set table width in HTML?
- How to use image height and width attribute in HTML Page?
- How to set cell padding in HTML?
- How to set width and height of an element using jQuery?
- How do I set browser width and height in Selenium WebDriver?
- How to set the height/width of a Label widget in Tkinter?
- How to set the min and max height or width of a Frame in Tkinter?
- How to set height equal to the dynamic width (CSS fluid layout) in JavaScript?
- How can I set an ImageView's width and height programmatically in Android?
- How I can set the width and height of a JavaScript alert box?
- Set the width of the element in HTML
- How can I set an ImageView's width and height programmatically in Android using Kotlin?
- Why cannot I use iframe absolute positioning to set height/width

Advertisements