bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/CSS/CSS Foundations
CSS•CSS Foundations

CSS Table Size (Width and Height)

CSS Table Width

The CSS width property is used to set the width of a table.

The width can be set

  • in percent (%)
  • as a fixed length (px)
  • by the auto keyword

CSS Table Width in Percent

To create a table that spans the entire screen (full-width), use width: 100%; :

FirstnameLastnameSavings

Example

Formatted code
table {
  width: 100%;
}

Live preview

To create a table that spans half the page, use width: 50%; :

FirstnameLastnameSavings

Example

Formatted code
table {
  width: 50%;
}

Live preview

CSS Table Width in a Fixed Width

To create a table with a fixed width, use width: 500px :

FirstnameLastnameSavings

Example

Formatted code
table {
  width: 500px;
}

Live preview

CSS Table Width Using auto

To let the browser calculate the width, use width: auto; :

FirstnameLastnameSavings

Example

Formatted code
table {
  width: auto;
}

Live preview

CSS Table Height

The CSS height property is used to set the height of a table.

The height can be set

  • in percent (%)
  • as a fixed length (px)
  • by the auto keyword

The example below sets the height of the table headers (<th>) to 70px:

FirstnameLastnameSavings

Example

Formatted code
th {
  height: 70px;
}

Live preview

Previous

CSS Tables

Next

CSS Table Alignment