HTML5 – The grid system

The grid system is a layout system that allows developers to create responsive and flexible grid-based layouts using rows and columns.

HTML5 introduced a new element called <table>, which is used to create a grid layout. The <table> element consists of rows and columns, and each row and column is represented by a <tr> and <td> element, respectively.

Here is an example of how to use the <table> element to create a grid layout:

<table>
  <tr>
    <td>Column 1</td>
    <td>Column 2</td>
    <td>Column 3</td>
  </tr>
  <tr>
    <td>Column 4</td>
    <td>Column 5</td>
    <td>Column 6</td>
  </tr>
</table>

In this example, the <table> element contains two rows, and each row contains three columns. The <td> elements represent the cells of the table, and the content inside each cell is displayed as text.

You can customize the appearance and behavior of the grid system using CSS. For example, you can use the width, height, padding, and margin properties to control the size and spacing of the rows and columns, and the border property to add a border around the cells.

Here is an example of how to use CSS to customize the grid system:

table {
  width: 100%;
  border-collapse: collapse;
}

td {
  border: 1px solid #ddd;
  padding: 8px;
}

tr:nth-child(even) {
  background-color: #f2f2f2;
}

In this example, the width property is used to set the width of the table to 100%, which makes it responsive and flexible. The border-collapse property is used to collapse the borders between the cells, and the border property is used to add a border around the cells. The padding property is used to add spacing inside the cells, and the tr:nth-child(even) selector is used to apply a background color to the even rows.