HTML Table Sizes
HTML tables can have different sizes for each column, row or the entire table.
We can specify the HTML table width using the CSS width property. It can be specify in pixels or percentage.
Here I am using style attribute with the width or height properties to specify the size of a table, row or column.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Tutorial</title>
<style>
table, th, td {
border: 2px solid green;
border-collapse: collapse;
}
</style>
</head>
<body>
<table style="width:100%">
<tr>
<th>Book Name</th>
<th>Author</th>
<th>Genres</th>
</tr>
<tr>
<td>Ghanshyam Shastri</td>
<td>Saras Azad</td>
<td>Crime Drama</td>
</tr>
<tr>
<td>Lovely Revolution</td>
<td>Saras Azad</td>
<td>Romance Drama</td>
</tr>
<tr>
<td>Madly in Love</td>
<td>Saras Azad</td>
<td>Love Story</td>
</tr>
</table>
</body>
</html>
Output :

Because I set the width to 100% in this case, the table fills the entire browser window. Table width can be changed appropriately.
Table Column Width
To set the size of a specific column, add the style attribute on a <th> or <td> element:
Example:
<!DOCTYPE html>
<html>
<head>
<title>HTML Tutorial</title>
<style>
table, th, td {
border: 2px solid green;
border-collapse: collapse;
}
</style>
</head>
<body>
<table style="width:100%">
<tr>
<!-- Here is the modified code for table cell width-->
<th style="width:70%">Book Name</th>
<th>Author</th>
<th>Genres</th>
</tr>
<tr>
<td>What happened on Saturday night</td>
<td>Saras Azad</td>
<td>Crime Drama</td>
</tr>
<tr>
<td>Lovely Revolution</td>
<td>Saras Azad</td>
<td>Romance Drama</td>
</tr>
<tr>
<td>Madly in Love</td>
<td>Saras Azad</td>
<td>Love Story</td>
</tr>
</table>
</body>
</html>
Output :

Table Row Height
To set the height of a specific row, add the style attribute on a table row element:
HTML Code:
<!DOCTYPE html>
<html>
<head>
<title>HTML Tutorial</title>
</head>
<body>
<table style="width:100%">
<tbody><tr>
<th>Book Name</th>
<th>Author</th>
<th>Genres</th>
</tr>
<tr>
<td>What happened on Saturday night</td>
<td>Saras Azad</td>
<td>Crime Drama</td>
</tr>
<tr style="height:100px">
<td>Lovely Revolution</td>
<td>Saras Azad</td>
<td>Romance Drama</td>
</tr>
<tr>
<td>Madly in Love</td>
<td>Saras Azad</td>
<td>Love Story</td>
</tr>
</tbody></table>
</body>
</html>
CSS Code : (Inside head tag)
<style>
table, th, td {
border: 2px solid red;
border-collapse: collapse;
}
</style>
Output :

- Home
- Java
- Java Fundamentals
- What is Java
- History of Java
- Java Version History
- Local Environment Set-up
- First Java Program
- How to set ‘Path’ env variable
- JDK, JRE, and JVM
- Object Oriented Programming
- Java Data Types
- Classes in Java
- Objects in Java
- Interfaces in java
- Class attributes and methods
- Methods In Java
- Variables and Constants in Java
- Java packages and Imports
- Access Modifiers In Java
- Java Operators
- Constructors in Java
- Control Statements – If else
- Control Statements – Loops
- Arrays in Java
- Java Abstraction
- Java Inheritance
- Polymorphism
- Java Exception Handling
- Strings in Java
- File IO
- Java Miscellaneous
- Design Patterns
- Java Fundamentals
- Collections
- Multithreading
- Java New Features
- Servlet
- JSP
- Spring
- Spring-Introduction
- First Spring Application
- Setter Injection
- Constructor injection
- Spring annotations
- Autowiring
- @Autowired Annotation Spring
- Spring MVC
- Spring JdbcTemplate
- Spring jdbcTemplate with MySQL
- Spring AOP
- Spring AOP Examples
- Various pointcut expressions in Spring AOP
- Download and configure Tomcat server
- Hibernate
- Architecture
- Hibernate Example
- First Hibernate Application (using xml configuration)
- First Hibernate Application (using annotations)
- JPA/HB – annotations
- Hibernate Identifiers
- Hibernate Generator Classes
- Save vs saveOrUpdate vs persist in Hibernate
- Inheritance Mapping in Hibernate
- Inheritance Mapping using annotations
- Hibernate Mapping
- Hibernate Query Language (HQL)
- HCQL Hibernate Criteria Query Language
- Hibernate Named Query
- Hibernate Caching
- Second Level Cache
- Spring Boot
- Spring Boot Basics
- Spring Boot Web
- Spring Boot Exception Handling
- Service discovery using Netflix Eureka
- Springboot OpenAPI/Swagger3
- Zuul Proxy Server + Routing
- Spring Cloud Gateway
- Spring Boot Security
- Circuit Breaker using Spring Boot Hystrix
- Interservice Communication
- Spring Boot Hateoas Links Example
- Lombok api
- Spring Boot with Mongo DB
- Load Balancer in Springboot
- Spring Boot Testing
- Spring Web Flux
- Database
- Web Service
- HTML
- Blog & Programs
- Docker
- Trainings
- Home
- Java
- Java Fundamentals
- What is Java
- History of Java
- Java Version History
- Local Environment Set-up
- First Java Program
- How to set ‘Path’ env variable
- JDK, JRE, and JVM
- Object Oriented Programming
- Java Data Types
- Classes in Java
- Objects in Java
- Interfaces in java
- Class attributes and methods
- Methods In Java
- Variables and Constants in Java
- Java packages and Imports
- Access Modifiers In Java
- Java Operators
- Constructors in Java
- Control Statements – If else
- Control Statements – Loops
- Arrays in Java
- Java Abstraction
- Java Inheritance
- Polymorphism
- Java Exception Handling
- Strings in Java
- File IO
- Java Miscellaneous
- Design Patterns
- Java Fundamentals
- Collections
- Multithreading
- Java New Features
- Servlet
- JSP
- Spring
- Spring-Introduction
- First Spring Application
- Setter Injection
- Constructor injection
- Spring annotations
- Autowiring
- @Autowired Annotation Spring
- Spring MVC
- Spring JdbcTemplate
- Spring jdbcTemplate with MySQL
- Spring AOP
- Spring AOP Examples
- Various pointcut expressions in Spring AOP
- Download and configure Tomcat server
- Hibernate
- Architecture
- Hibernate Example
- First Hibernate Application (using xml configuration)
- First Hibernate Application (using annotations)
- JPA/HB – annotations
- Hibernate Identifiers
- Hibernate Generator Classes
- Save vs saveOrUpdate vs persist in Hibernate
- Inheritance Mapping in Hibernate
- Inheritance Mapping using annotations
- Hibernate Mapping
- Hibernate Query Language (HQL)
- HCQL Hibernate Criteria Query Language
- Hibernate Named Query
- Hibernate Caching
- Second Level Cache
- Spring Boot
- Spring Boot Basics
- Spring Boot Web
- Spring Boot Exception Handling
- Service discovery using Netflix Eureka
- Springboot OpenAPI/Swagger3
- Zuul Proxy Server + Routing
- Spring Cloud Gateway
- Spring Boot Security
- Circuit Breaker using Spring Boot Hystrix
- Interservice Communication
- Spring Boot Hateoas Links Example
- Lombok api
- Spring Boot with Mongo DB
- Load Balancer in Springboot
- Spring Boot Testing
- Spring Web Flux
- Database
- Web Service
- HTML
- Blog & Programs
- Docker
- Trainings
- Home
- Java
- Java Fundamentals
- What is Java
- History of Java
- Java Version History
- Local Environment Set-up
- First Java Program
- How to set ‘Path’ env variable
- JDK, JRE, and JVM
- Object Oriented Programming
- Java Data Types
- Classes in Java
- Objects in Java
- Interfaces in java
- Class attributes and methods
- Methods In Java
- Variables and Constants in Java
- Java packages and Imports
- Access Modifiers In Java
- Java Operators
- Constructors in Java
- Control Statements – If else
- Control Statements – Loops
- Arrays in Java
- Java Abstraction
- Java Inheritance
- Polymorphism
- Java Exception Handling
- Strings in Java
- File IO
- Java Miscellaneous
- Design Patterns
- Java Fundamentals
- Collections
- Multithreading
- Java New Features
- Servlet
- JSP
- Spring
- Spring-Introduction
- First Spring Application
- Setter Injection
- Constructor injection
- Spring annotations
- Autowiring
- @Autowired Annotation Spring
- Spring MVC
- Spring JdbcTemplate
- Spring jdbcTemplate with MySQL
- Spring AOP
- Spring AOP Examples
- Various pointcut expressions in Spring AOP
- Download and configure Tomcat server
- Hibernate
- Architecture
- Hibernate Example
- First Hibernate Application (using xml configuration)
- First Hibernate Application (using annotations)
- JPA/HB – annotations
- Hibernate Identifiers
- Hibernate Generator Classes
- Save vs saveOrUpdate vs persist in Hibernate
- Inheritance Mapping in Hibernate
- Inheritance Mapping using annotations
- Hibernate Mapping
- Hibernate Query Language (HQL)
- HCQL Hibernate Criteria Query Language
- Hibernate Named Query
- Hibernate Caching
- Second Level Cache
- Spring Boot
- Spring Boot Basics
- Spring Boot Web
- Spring Boot Exception Handling
- Service discovery using Netflix Eureka
- Springboot OpenAPI/Swagger3
- Zuul Proxy Server + Routing
- Spring Cloud Gateway
- Spring Boot Security
- Circuit Breaker using Spring Boot Hystrix
- Interservice Communication
- Spring Boot Hateoas Links Example
- Lombok api
- Spring Boot with Mongo DB
- Load Balancer in Springboot
- Spring Boot Testing
- Spring Web Flux
- Database
- Web Service
- HTML
- Blog & Programs
- Docker
- Trainings