Example HTML With Table: A Complete Guide to Creating Effective Data Tables

HTML tables are an essential part of web development, as they allow us to display data in a structured, easy-to-read format. In this article, we'll dive into examples of HTML tables, their common attributes, and best practices for using them.

Responsive HTML Table With Rounded Corners
Responsive HTML Table With Rounded Corners

Tables are defined with the `

` tag and typically consist of rows (``), data cells (`
`), and header cells (``). Let's start with a basic example:

HTML Basic Tables
HTML Basic Tables

Creating a Simple HTML Table

Here's a simple table with two rows and three columns:

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

NameAgeCountry
John30USA
Jane28Canada

Table Headers and Rows

HTML Table
HTML Table

The first row in our table consists of header cells (`

`), which set the columns' titles. The following rows contain data cells (``).

You can also use the `scope` attribute in `

` tags to explicitly define the scope of the header cells. For example:

NameAgeCountry
John30USA
Jane28Canada
Welcome to SiteRaw
Welcome to SiteRaw

Table Attributes

Tables can have several attributes to enhance their functionality and appearance. Here are a few common ones:

  • border: Specifies whether, and if so, how wide the borders between cells should be.
  • width and height: Set the dimensions of the table in pixels.
  • align: Aligns the content within the cells (e.g., left, right, or center).
HTML Tables Tags Tutorial with Example โ€” TutorialBrain
HTML Tables Tags Tutorial with Example โ€” TutorialBrain

Layout and Formatting

Tables can be combined with other HTML elements, like `

` and ``, to create complex layouts. However, it's essential to keep in mind that using tables for layout can cause accessibility issues.

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
CSS Table Layout
CSS Table Layout
๐Ÿ“Š Combine Table Cells in HTML
๐Ÿ“Š Combine Table Cells in HTML
the table borders for different types of text
the table borders for different types of text
Tables in HTML
Tables in HTML
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
Complete Beginner HTML Master Notes
Complete Beginner HTML Master Notes
29 Free CSS3 & HTML Table Templates 2026 - Colorlib
29 Free CSS3 & HTML Table Templates 2026 - Colorlib
Responsive Table V1 - Free HTML/CSS Table Template 2026 - Colorlib
Responsive Table V1 - Free HTML/CSS Table Template 2026 - Colorlib
HTML Cheat Sheet ๐Ÿ“„โœจ Quick Guide for Beginners
HTML Cheat Sheet ๐Ÿ“„โœจ Quick Guide for Beginners
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
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
Top 9 HTML Table Builders to use Free
Top 9 HTML Table Builders to use Free
A Detailed Guide to HTML Tables | Simplilearn
A Detailed Guide to HTML Tables | Simplilearn
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
a screenshot of a computer screen with the text'html tables'on it
a screenshot of a computer screen with the text'html tables'on it
Sortable Table with HTML & Javascript
Sortable Table with HTML & Javascript
Student Registration Form in HTML with CSS | Completely Free
Student Registration Form in HTML with CSS | Completely Free
The table-layout property in CSS
The table-layout property in CSS
HTML,CSS JAVASCRIPT cheatsheet
HTML,CSS JAVASCRIPT cheatsheet

It's generally recommended to use CSS for layout and apply tables only for tabular data. This ensures better semantics, accessibility, and ease of styling.

Tables and Accessibility

When creating tables, it's crucial to consider accessibility. Adding proper headers (using `

`) and using `scope` or `abbr` attributes help screen readers present table data effectively.

Additionally, use `

` to provide a text description of what the table contains, and ensure that the table makes sense even when presented out of context (e.g., without surrounding text).

Tables and Responsive Design

In responsive web design, tables can be challenging to handle, as they may become too wide or require excessive scrolling on smaller screens. To address this, use CSS to control the table's width and wrap long table data.

You can also use the CSS `display` property to convert tables into a more flexible format, like a grid or list, for better responsiveness.

In practice, HTML tables are a versatile tool for presenting data. By understanding their structure, attributes, and best practices, you can create tables that are not only functional but also accessible and visually appealing.