HTML CSS JAVASCRIPT PYTHON JAVA PHP BOOTSTRAP

HTML Tables

HTML tables are used to display data in rows and columns. They are commonly used for showing structured information such as schedules, prices, reports, and comparison data.

Basic HTML Table

An HTML table is created using the <table> element. Each row is defined with <tr>, and each cell is defined with <td>.

Name Age City
Ali 22 Lahore

Table Headers

The <th> element is used to define table header cells. Table headers are bold and centered by default.

Name Age City
Ahmed 25 Karachi

Table Caption

The <caption> tag is used to add a title or description to a table.

Student Information
Name Marks
Sara 88

Rowspan and Colspan

The rowspan and colspan attributes allow cells to span multiple rows or columns.

Name Contact
Usman Email Phone

Table Border

Borders can be added using the border attribute or preferably using CSS.

Product Price
Book $10

Best Practices for Tables

Common Mistakes with Tables

Tip: Combine HTML tables with CSS for better design, responsiveness, and readability.