UNIT 3 – Tables: Inserting a table, Table attributes, table headers.
1. Introduction to HTML Tables
HTML tables are used to display data in rows and columns. Tables are very useful for presenting structured information such as marks, timetables, reports and records. An HTML table is created using the <table> tag along with row, column and header tags.
2. Inserting a Table in HTML
An HTML table is created using the <table> tag. Inside the table, <tr> is used to define table rows and <td> is used to define table data (cells).
Important Short Answer Questions
1. What is an HTML table?
An HTML table is used to display data in rows and columns on a web page.
2. Which tag is used to create a table?
The <table> tag is used to create a table.
3. Which tag is used to create a table row?
The <tr> tag is used to create a table row.
4. Which tag is used to insert table data?
The <td> tag is used to insert table data.
Important Long Answer Question
Explain how to insert a table in HTML.
An HTML table is used to arrange data in rows and columns.
To insert a table, the <table> tag is used as the main container.
Each row of the table is defined using the <tr> tag and each cell inside the row is defined using the <td> tag.
Tables help in presenting structured data clearly and neatly.
They are commonly used to display information such as student marks, schedules and records on web pages.
3. Table Attributes
Table attributes are used to control the appearance of a table. Common attributes include border, cellpadding, cellspacing, width and align.
Important Short Answer Questions
1. What are table attributes?
Table attributes are used to control the appearance and layout of an HTML table.
2. Name any two table attributes.
- border
- cellpadding
3. Which attribute is used to add a border to a table?
The border attribute is used to add a border to a table.
Important Long Answer Question
Explain table attributes in HTML.
Table attributes are used to change the appearance and layout of an HTML table.
The border attribute is used to add a border around the table.
The cellpadding attribute adds space inside table cells, while cellspacing controls the space between cells.
The width attribute sets the width of the table.
These attributes help improve the visual presentation and readability of table data.
4. Table Headers
Table headers are used to define heading cells in a table. The <th> tag is used to create table header cells, which are displayed in bold and centered by default.
Important Short Answer Questions
1. What is a table header?
A table header is used to define the heading of a column or row in an HTML table.
It describes the type of data in that column or row.
2. Which tag is used for table headers?
The <th> tag is used for table headers.
3. How is <th> different from <td>?
<th> is used for table headings and its text is bold and center-aligned by default.
<td> is used for table data and its text is normal and left-aligned by default.
Important Long Answer Question
Explain table headers in HTML.
Table headers are used to label columns or rows in a table.
They are created using the <th> tag.
Header cells are displayed in bold text and centered by default, making them easily distinguishable from normal table data cells.
Table headers improve the clarity and understanding of table content.
They are especially useful when tables contain large amounts of data.
