Master W3Schools Table Width: Complete Guide To HTML Table Sizing

Logan Jul 13, 2026

Ever faced the challenge of tables extending beyond their container in a web page? Controlling the width of tables in HTML can be a breeze with the right approach. W3schools, a popular online resource for learning web development, offers clear guidance on this topic. Let's explore how to set table width using simple HTML techniques and W3Schools' insights.

Classroom Layout Desk & Table Sizes
Classroom Layout Desk & Table Sizes

Tables, by default, extend to fit their content. This can cause an unpleasant user experience, especially on smaller screens. Setting a fixed or maximum width for tables ensures a clean, responsive layout that adapts to different devices.

Mixed Times Tables Worksheets 1-12 | Free Printable PDF
Mixed Times Tables Worksheets 1-12 | Free Printable PDF

Setting a Fixed Width Table

For a table to maintain a consistent width across various screen sizes, you can define a fixed width. Here's how:

an info graphic showing the height and width of people sitting at a table with their feet up
an info graphic showing the height and width of people sitting at a table with their feet up

The   attribute is used to set the width of a table in pixels. For instance,  <table style="width:500px;"></table></code> sets the width of the table to 500 pixels.

Using CSS

Altura mesa para criança
Altura mesa para criança

Alternatively, you can use CSS to set the table width. This method provides more flexibility, allowing you to adjust the width using various units like em,REM, and percentages.

For example, <style><code> table {   width: 100%; }</code></style> can make your table span the full width of its container.

Setting a Maximum Width Table

printable worksheet for the times table
printable worksheet for the times table

Setting a maximum width is useful when you want the table to fill the container but not exceed a certain size. This ensures readability for wider tables and supports responsiveness on smaller screens.

The  attribute can also be used to set a maximum width. For instance,<table style="max-width: 500px;"></table> sets the maximum width of the table to 500 pixels. If necessary, the table will scroll horizontally.

Responsive Design

the table to 30 is shown in red and blue, with numbers on each side
the table to 30 is shown in red and blue, with numbers on each side

To achieve a truly responsive design, combine fixed or maximum widths with media queries. Media queries enable you to apply different styles for different screen sizes, ensuring an optimal viewing experience.<code> <style><code> @media screen and (max-width: 600px) {    table {      width: 100%; } }</code></style> </code>makes tables full-width on screens 600 pixels wide or less.

Remember, W3schools not only teaches but also provides useful tools like the 'Try it Yourself' editor. This empowers you to experiment and learn by applying these concepts directly on their platform.

Multiplication Table of 3 | 3 Times Table
Multiplication Table of 3 | 3 Times Table
children's table and chair with measurements
children's table and chair with measurements
a red table with writing on it in front of two wooden chairs and a wall
a red table with writing on it in front of two wooden chairs and a wall
a room with several tables, chairs and a large rug on the floor in front of it
a room with several tables, chairs and a large rug on the floor in front of it
the table and chairs are measurements for each chair
the table and chairs are measurements for each chair
Tables from 13 to 20 - Learn 13 to 19 Tables [PDF Download]
Tables from 13 to 20 - Learn 13 to 19 Tables [PDF Download]
4,000+ Free Students & School Images
4,000+ Free Students & School Images
the size and measurements chart for children's table heights, including two tables
the size and measurements chart for children's table heights, including two tables
the table has different colors and numbers for each individual to see in this chart,
the table has different colors and numbers for each individual to see in this chart,
Tables 2 to 20 - Multiplication Tables 2 to 20 Pdf Download
Tables 2 to 20 - Multiplication Tables 2 to 20 Pdf Download
Choosing the Best Table Style | Kaplan Early Learning Company
Choosing the Best Table Style | Kaplan Early Learning Company
the times table for kids to learn how to use it
the times table for kids to learn how to use it
Blank Printable Multiplication Table Chart 1 to 20 PDF Free
Blank Printable Multiplication Table Chart 1 to 20 PDF Free
Classroom - Shapes - Semi-Circle (Tables) Dimensions & Drawings | Dimensions.com
Classroom - Shapes - Semi-Circle (Tables) Dimensions & Drawings | Dimensions.com
the table shows different types of computer equipment
the table shows different types of computer equipment
an empty classroom with desks and chairs
an empty classroom with desks and chairs
an overhead view of a classroom with desks and chairs, including one green table
an overhead view of a classroom with desks and chairs, including one green table
various types of children's table and chairs with measurements for each one, including the height
various types of children's table and chairs with measurements for each one, including the height
a man sitting on top of a table next to a tall stack of tables with seats
a man sitting on top of a table next to a tall stack of tables with seats
furniture for daycare center greencleandesigns.com child care furniture
furniture for daycare center greencleandesigns.com child care furniture

In web development, understanding and controlling table widths is crucial for creating clean, responsive layouts. Mastering these techniques, coupled with responsive design approaches, ensures your tables adapt and look great on any device. So, why not visit W3schools today and start practicing?