Courses / Application of ICT (GEN-103) – BS 1st Semester

Week 16 Lab 16 – HTML: Creating Lists and Tables

Week 16 – HTML Basics: Structure, Text Formatting and Lists · 90 min read · 9 MCQs to check yourself

Lab objectives

Create unordered, ordered, definition and nested lists; create tables with headings, borders, colours, colspan and rowspan.

Task 1 – Lists

Create lists.html:

<!DOCTYPE html>
<html>
<head><title>Lists Practice</title></head>
<body>
  <h2>1. Unordered list (Input devices)</h2>
  <ul type="square">
    <li>Keyboard</li>
    <li>Mouse</li>
    <li>Scanner</li>
  </ul>

  <h2>2. Ordered list (SDLC phases)</h2>
  <ol type="I">
    <li>Planning</li>
    <li>Analysis</li>
    <li>Design</li>
    <li>Development</li>
    <li>Testing</li>
  </ol>

  <h2>3. Ordered list starting from 5</h2>
  <ol start="5">
    <li>Fifth item</li>
    <li>Sixth item</li>
  </ol>

  <h2>4. Definition list (Glossary)</h2>
  <dl>
    <dt>LAN</dt>
    <dd>Local Area Network – covers a building or campus.</dd>
    <dt>WAN</dt>
    <dd>Wide Area Network – covers countries; the Internet is the largest WAN.</dd>
  </dl>

  <h2>5. Nested list</h2>
  <ol>
    <li>Hardware
      <ul type="circle">
        <li>Input devices</li>
        <li>Output devices</li>
      </ul>
    </li>
    <li>Software
      <ul type="disc">
        <li>System software</li>
        <li>Application software</li>
      </ul>
    </li>
  </ol>
</body>
</html>

Try every type value: ul → disc, circle, square; ol → 1, A, a, I, i.

Task 2 – Tables

Create tables.html:

<!DOCTYPE html>
<html>
<head><title>Tables Practice</title></head>
<body>
  <table border="1" cellpadding="8" cellspacing="0" width="70%" align="center">
    <caption><b>BS IT – ICT Marks</b></caption>
    <tr bgcolor="#1565C0">
      <th><font color="white">Roll No</font></th>
      <th><font color="white">Name</font></th>
      <th><font color="white">Mid</font></th>
      <th><font color="white">Final</font></th>
      <th><font color="white">Total</font></th>
    </tr>
    <tr>
      <td>101</td><td>Ayesha</td><td align="center">26</td><td align="center">44</td><td align="center">70</td>
    </tr>
    <tr bgcolor="#E3F2FD">
      <td>102</td><td>Bilal</td><td align="center">22</td><td align="center">40</td><td align="center">62</td>
    </tr>
    <tr>
      <td>103</td><td>Sara</td><td align="center">28</td><td align="center">47</td><td align="center">75</td>
    </tr>
  </table>
</body>
</html>

Task 3 – colspan and rowspan (timetable)

<table border="1" cellpadding="6">
  <tr>
    <th>Day</th>
    <th>8:00–9:00</th>
    <th>9:00–10:00</th>
    <th>10:00–11:00</th>
  </tr>
  <tr>
    <td>Monday</td>
    <td>ICT</td>
    <td colspan="2" align="center">ICT Lab (2 hours)</td>
  </tr>
  <tr>
    <td>Tuesday</td>
    <td rowspan="2" align="center">English</td>
    <td>Maths</td>
    <td>Physics</td>
  </tr>
  <tr>
    <td>Wednesday</td>
    <td>Islamic Studies</td>
    <td>Maths</td>
  </tr>
</table>

Observe: colspan="2" merges two columns; rowspan="2" merges two rows, so the next row has one fewer <td>.

Lab exercise (submit)

  1. syllabus.html – an ordered list of the 17 weeks with a nested unordered list of 2–3 topics under each week; a definition list of 6 ICT terms.
  2. timetable.html – your weekly class timetable with caption, coloured header row, at least one colspan and one rowspan, border 1, cellpadding 6.

HTML Lists Tutorial (Dave Gray)

HTML table Tag: HTML Tutorial for Beginners

Short and long questions

1. Write HTML code for an ordered list of three input devices numbered A, B, C.

Model answer

<ol type="A"> <li>Keyboard</li> <li>Mouse</li> <li>Scanner</li> </ol>

2. Write HTML code to create a class timetable that uses colspan and rowspan, with a caption and a coloured header row.

Model answer
<table border="1" cellpadding="6" cellspacing="0">
  <caption>BS IT Timetable</caption>
  <tr bgcolor="lightblue">
    <th>Day</th><th>8–9</th><th>9–10</th><th>10–11</th>
  </tr>
  <tr>
    <td>Monday</td><td>ICT</td>
    <td colspan="2" align="center">ICT Lab</td>
  </tr>
  <tr>
    <td>Tuesday</td>
    <td rowspan="2">English</td>
    <td>Maths</td><td>Physics</td>
  </tr>
  <tr>
    <td>Wednesday</td><td>Islamic Studies</td><td>Maths</td>
  </tr>
</table>

<caption> gives the title, bgcolor colours the header row, colspan="2" makes "ICT Lab" occupy two time slots, and rowspan="2" makes "English" cover Tuesday and Wednesday, so Wednesday's row has one fewer cell.

3. Write HTML code for a table with two columns (Device, Type) and two rows of data with border 1.

Model answer

<table border="1"> <tr><th>Device</th><th>Type</th></tr> <tr><td>Keyboard</td><td>Input</td></tr> <tr><td>Printer</td><td>Output</td></tr> </table>

This lesson ends with a quiz of 9 MCQs. Open the lesson on PrepOasis to take it and save your progress.

Previous: Week 16 Theory – Introduction to HTML, Text Formatting and Lists · Next: Week 17 Theory – Hyperlinks, Images, Colours, Frames and Tables in HTML

All lessons in Application of ICT (GEN-103) – BS 1st Semester