Web Technology I · Unit 3
HTML Content and Tables
Exam-focused notes for HTML Content and Tables (Web Technology I, BIT251): what the TU syllabus asks and how it has actually been tested, with 3 solved past questions from this unit.
HTML Content and Tables in short
This chapter covers the HTML tags used to present lists, tables, special characters and links. These are used in almost every web page.
What this unit covers
- HTML lists ordered and unordered
- HTML table structure and attributes
- Table borders and styling
- HTML entities and special characters
- HTML links and anchors
HTML table structure and attributes
2079 · 5 marks
What is table in HTML? Create a HTML page containing a DIV with name "divtb". The divtb should contain a table as below[Note the border should be dotted ] [5]
Show solved answerHide answer
HTML Table - Model Answer
What is a Table in HTML?
An HTML table is a structured way to display data in rows and columns format. Tables are created using the <table> tag along with several related tags:
| Tag | Description |
|---|---|
<table> | Defines the table |
<tr> | Defines a table row |
<th> | Defines a table header cell (bold & centered by default) |
<td> | Defines a table data cell |
<caption> | Defines a table caption/title |
Tables are used to organize and present data in a grid-like structure on a webpage.
HTML Page with DIV "divtb" containing a Dotted Border Table
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Example</title>
<style>
#divtb {
width: 50%;
margin: 20px auto;
}
#divtb table {
width: 100%;
border-collapse: collapse;
}
#divtb table,
#divtb th,
#divtb td {
border: 2px dotted black;
padding: 8px;
text-align: center;
}
#divtb th {
background-color: #cccccc;
}
</style>
</head>
<body>
<div id="divtb">
<table>
<caption><strong>Student Table</strong></caption>
<tr>
<th>S.N.</th>
<th>Name</th>
<th>Age</th>
<th>Address</th>
</tr>
<tr>
<td>1</td>
<td>Ram</td>
<td>20</td>
<td>Kathmandu</td>
</tr>
<tr>
<td>2</td>
<td>Sita</td>
<td>22</td>
<td>Pokhara</td>
</tr>
<tr>
<td>3</td>
<td>Hari</td>
<td>21</td>
<td>Chitwan</td>
</tr>
</table>
</div>
</body>
</html>
Key Points to Note
id="divtb"is used to identify the<div>elementborder: 2px dotted blackapplies the dotted border to the table,<th>, and<td>elementsborder-collapse: collapseensures borders between cells are merged into a single border<th>tags are used for header row (S.N., Name, Age, Address)<td>tags are used for data rows
0 · 10 marks
Write HTML script to generate following output. Create a table like below. Set link to www.facebook.com in the text "Null". The title of your HTML page should be "Test". The table should be in a div having id dv1. (explanation: The below table is about the use of rows and columns, use of rows , use of subscript and supescript)[10]
HTML entities and special characters
2080.2 · 5 marks
Write HTML script to display following output in a division under body section. a) The ampersand (and) sign: & b.) equation $3x^2 + 2x_1 y < 4$. $45 < > 30$ [5]
Make Unit 3 stick
Practice BIT251 with flashcards & quizzes