Master HTML CSS Table Tutorial With Step By Step Guide

Welcome to our comprehensive HTML CSS table tutorial, where we'll dive into the world of creating and styling tables using HTML and CSS. By the end of this guide, you'll have a solid understanding of how to design effective and visually appealing tables that present data in an organized manner.

๐Ÿงพ How to Create Tables in HTML
๐Ÿงพ How to Create Tables in HTML

Before we jump in, let's assume you have a basic understanding of HTML and CSS. If not, we recommend checking out our beginner's guide to these languages first. Now, let's get started with the fundamentals of creating tables with HTML.

29 Free CSS3 & HTML Table Templates 2026 - Colorlib
29 Free CSS3 & HTML Table Templates 2026 - Colorlib

Creating HTML Tables

In HTML, tables are created using the <table> tag, with rows defined by the <tr> tag, and cells (or columns) by the <td> tag. Here's a simple example:

Welcome to SiteRaw
Welcome to SiteRaw
Header 1 Header 2
Data 1 Data 2

To add more rows or columns, simply nest more <tr> and <td> tags accordingly. You can also use the <th> tag for table headers, which styles the cell as bold text by default.

CSS Table Layout
CSS Table Layout

Table Attributes

Several attributes can be applied to the <table> tag to control table layout and behavior. Some useful ones include:

  • width: Sets the table's width in pixels or as a percentage.
  • border: Adds a border around the table (default is '1').
  • cellspacing: Sets the space between cell borders in pixels.
  • cellpadding: Adds space within cells in pixels.
HTML Basic Tables
HTML Basic Tables

For instance, the following table has a width of 300 pixels, a border of '2,' and 10 pixels of space between cells and within cells:

Table Head and Footer

You can add header and footer rows to your table using the <thead> and <tfoot> tags respectively. This helps improve accessibility and semantics:

๐Ÿ“Š Combine Table Cells in HTML
๐Ÿ“Š Combine Table Cells in HTML
Header 1 Header 2
Data 1 Data 2
Footer 1 Footer 2

Styling Tables with CSS

How To Create Responsive Tables In HTML CSS
How To Create Responsive Tables In HTML CSS
HTML Tables Tags Tutorial with Example โ€” TutorialBrain
HTML Tables Tags Tutorial with Example โ€” TutorialBrain
Responsive HTML CSS Table
Responsive HTML CSS Table
How to Expand and Collapse Tables in HTML Using CSS
How to Expand and Collapse Tables in HTML Using CSS
Responsive HTML Table With Rounded Corners
Responsive HTML Table With Rounded Corners
Simple Editable Table In HTML Javascript
Simple Editable Table In HTML Javascript
40 Best CSS Table Templates For Creating Appealing Tables 2026
40 Best CSS Table Templates For Creating Appealing Tables 2026
CSV To HTML Table In Javascript
CSV To HTML Table In Javascript
HOW TO MERGE TABLE CELLS IN HTML
HOW TO MERGE TABLE CELLS IN HTML
an info sheet describing the different types of web pages and how they are used to create them
an info sheet describing the different types of web pages and how they are used to create them
Creating Tables in HTML- A Complete Guide.
Creating Tables in HTML- A Complete Guide.
The table-layout property in CSS
The table-layout property in CSS
Sortable Table In HTML Javascript
Sortable Table In HTML Javascript
a computer screen with the text html and an image of a web page on it
a computer screen with the text html and an image of a web page on it
Sortable HTML Table With Javascript
Sortable HTML Table With Javascript
HTML Cheat Sheet ๐Ÿ“„โœจ Quick Guide for Beginners
HTML Cheat Sheet ๐Ÿ“„โœจ Quick Guide for Beginners
HTML input types
HTML input types
CSS Notes for Beginners (Easy + Quick Guide) ๐ŸŽจ
CSS Notes for Beginners (Easy + Quick Guide) ๐ŸŽจ
Colorful CSS Table | Styling Table With CSS | In Urdu/Hindi | #17 | Table In CSS
Colorful CSS Table | Styling Table With CSS | In Urdu/Hindi | #17 | Table In CSS
the different types of web pages are shown in red and white, as well as text
the different types of web pages are shown in red and white, as well as text

Now that we've covered the basics of creating tables in HTML, let's explore how to style them using CSS.

You can apply CSS styles to tables using class or ID selectors. For example, to set the background color of cells in a table with the class 'my-table,' you could use the following CSS rule:

```css .my-table td { background-color: lightgray; } ```

Styling Table Headers

To style table headers independently, you can target the <th> tag directly:

```css th { background-color: darkblue; color: white; font-weight: normal; } ```

Alignment and Padding

You can control the alignment of cells and the spacing within them using the text-align and padding properties respectively:

```css td, th { text-align: center; padding: 10px; } ```

With these CSS rules, you should have a solid foundation for creating and styling tables that are both functional and visually appealing. Keep practicing and exploring to master the intricacies of table design.

Remember, tables are a powerful tool for displaying data, but they should be used thoughtfully and judiciously. As a web developer, it's essential to understand when to use tables and when to consider alternative layouts like div containers with CSS grids or flexbox.

A well-designed table can be an invaluable asset to your users, helping them navigate, compare, or understand complex data. So, go forth and create! Happy coding!

Related Articles

Html Quick Start Html Structure Tutorial Tutorialspoint Hq Html Quick.reference Guide Html Tutorial Pdf Html Game Development Tutorial Html Quick Start Guide Tutorialspoint Html Online Editor Html5 Tutorial For Beginners Html Code Quizlet