MDN HTML Table Basics: Master the Essentials of Web Tables

Welcome to your comprehensive guide on HTML tables! As a developer, you'll find tables indispensable for displaying data in rows and columns. Let's delve into the basics, ensure your table is accessible, and explore some advanced techniques.

HTML Basic Tables
HTML Basic Tables

HTML tables are defined by the <table> tag, with <tr> defining rows, <th> for table headers, and <td> for table data. Here's a simple example:

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

Basic Table Structure

The table element is the container for your data, while <tr> groups row content. Let's create a table with a header and body:

Complete Beginner HTML Master Notes
Complete Beginner HTML Master Notes
Header 1 Header 2
Data 1 Data 2

Table Captions

HTML Table
HTML Table

Adding a caption describes the table's purpose, improving accessibility. Use the <caption> tag:

...
Sample Table

Table Headers

a red and black text description for a web page with an arrow pointing to it
a red and black text description for a web page with an arrow pointing to it

Using <th> defines headers, scoping them with "scope" attribute for screen readers: "col" for column headers, "row" for row headers:

...
Header 1 Header 2

Styling and Layout

the basic instructions for creating a web page with html and jtmll on it
the basic instructions for creating a web page with html and jtmll on it

Tables can be styled using CSS. Here, we'll add some basic styles:

...

an image of a table with many lines
an image of a table with many lines
a table that has some type of text in red and black on the bottom right hand corner
a table that has some type of text in red and black on the bottom right hand corner
๐Ÿ“Š Combine Table Cells in HTML
๐Ÿ“Š Combine Table Cells in HTML
Complete Beginner HTML Master Notes
Complete Beginner HTML Master Notes
a black and orange poster with text that says,'html chat sheet'on it
a black and orange poster with text that says,'html chat sheet'on it
HTML Tables Tags Tutorial with Example โ€” TutorialBrain
HTML Tables Tags Tutorial with Example โ€” TutorialBrain
HTML Cheat Sheet for Beginners | Basic Tags, Lists, Tables & Text Formatting
HTML Cheat Sheet for Beginners | Basic Tags, Lists, Tables & Text Formatting
an orange background with the words basic html elements in different font and numbers on it
an orange background with the words basic html elements in different font and numbers on it
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
Complete Beginner HTML Master Notes
Complete Beginner HTML Master Notes
HTML and CSS cheat sheets
HTML and CSS cheat sheets
A Detailed Guide to HTML Tables | Simplilearn
A Detailed Guide to HTML Tables | Simplilearn
Complete Beginner HTML Master Notes
Complete Beginner HTML Master Notes
an image of a computer screen with the words html and table part 1 on it
an image of a computer screen with the words html and table part 1 on it
an image of a table with numbers and symbols on the top right hand corner that says tables
an image of a table with numbers and symbols on the top right hand corner that says tables
HTML Cheat Sheet
HTML Cheat Sheet
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
tables in html table with text and images on the page, which is displayed below
tables in html table with text and images on the page, which is displayed below
the table borders for different types of text
the table borders for different types of text

Column Spanning

To span a column across multiple cells, use the "colspan" attribute:

...
Column 1 Column 2 and 3

Row Spanning

Similarly, use "rowspan" to create tall cells:

...
Row 1 and 2 Cell spans two rows Column 3

As you've seen, HTML tables allow for organized data presentation while keeping your code accessible and flexible. Happy coding!

Related Articles

Html Dom Document Body Is Dart Easy To Learn Dart List Methods Html 5 For Dummies Pdf Html & Css Essentials For Dummies Pdf Html Dom Document Ready What Is A Div In Html With Example Html Table Basics Html Div Tutorial Layout What Is Div In Html Code