One moment, we're cooking some code examples
Utilize tables to visually organize your data – a classic web design approach that proves the enduring relevance of tabular data.
A table in HTML consists of a <table>
element with table rows <tr>
and table data cells <td>
. To mark the heading of each column, you should use the table heading <th>
element.
A basic table with default styling.
In this example we have a simple table with some headings and data cells. We use some classes to highlight and align the table contents.
Item | Description | Price |
---|---|---|
Laptop | 15-inch, 8GB RAM, 512GB SSD | € 899.99 |
Smartphone | 6.5-inch display, 128GB, 5G | € 649.99 |
With this table the lines are made using tr:nth-child(even) this gives each even row a background color. By doing this you can make the content much easier to read
City | Population | Area (sq. mi) | Country |
---|---|---|---|
New York | 8,336,817 | 302.6 | United States |
Tokyo | 13,515,271 | 845.4 | Japan |
Beijing | 21,009,000 | 6,336.5 | China |
London | 8,982,000 | 607 | United Kingdom |
Here is a example of a way to use colour inside a table. We also made a availability bar with you can change the length of by adjusting the class Stock-100
Snack | Category | Price | Availability |
---|---|---|---|
Potato Chips | Salty | € 2.99 | In stock In stock |
Gummy Bears | Sweet | € 2.25 | In stock In stock |
Chocolate | Sweet | € 1.50 | Limited stock Limited stock |
Popcorn | Savory | € 3.25 | Out of stock Out of stock |
Pretzels | Savory | € 2.75 | In stock In stock |
Time for something really extraordinary.
Make responsive CSS styling extremely easy. Why not not mix a realtime resizable preview with responsive media queries? Yes! Now you can mix and match Realtime responsive media queries without resizing the browser.
We made this table responsive. we did this by using media queries. and if the screen is less than 600px tha layout will chane by using first-child
and last-child
by doing this we made the content inside the table clear to read.
Product | Category | Price | Availability |
---|---|---|---|
Mobile Phone | Electronics | € 879.99 | in stock |
Robot lawnmower | Home & Garden | € 999.99 | in stock |
Lip stick | Beauty | € 19.99 | out stock |
Cell span <colspan=""> and row span <rowspan=""> are used to join cells together to make a larger cell. You can join cells horizontally, vertically, or both.
We used hover
to make it more visible.
1 | 2 | 3 | 4 | 5 | 6 |
---|---|---|---|---|---|
<colspan="2"> | <rowspan="3"> | ||||
<rowspan="2"> | <rowspan="2" colspan="2"> | ||||