Day 3 Lab - HTML Tables and Images

This lesson introduces HTML tables for organizing data into rows and columns and the HTML image element for displaying pictures on webpages.

Learning Outcomes
  • Create HTML tables.
  • Use <thead>, <tr>, <th> and <td>.
  • Merge cells using colspan and rowspan.
  • Display local and online images.

HTML Tables

Tables display information in rows and columns.

<table border="1">
  <thead>
    <tr>
      <th>ENO</th>
      <th>ENAME</th>
      <th>ESAL</th>
      <th>EADDR</th>
    </tr>
  </thead>
  <tr>
    <td>100</td>
    <td>DURGA</td>
    <td>1000</td>
    <td>Hyd</td>
  </tr>
</table>
ENOENAMEESALEADDR
100DURGA1000Hyd
200SUNNY2000Mumbai
300Bunny3000Chennai

Merging Cells

colspan merges columns (left to right).

<th colspan="2">Student Details</th>
Student Details
NameAlex

rowspan merges rows (top to bottom).

<td rowspan="2">Alex</td>
AlexMaths
Science

Images in HTML

Images are displayed using the <img> tag.

AttributePurpose
srcImage path or URL
altAlternative text
widthImage width
heightImage height
<img src="flower.jpg" alt="Flower">

<img src="flower.jpg"
     alt="Flower"
     width="300"
     height="200">

<img src="https://example.com/image.jpg"
     alt="Online Image">

<a href="https://www.google.com">
   <img src="google.png" alt="Google">
</a>
Path Types
  • Relative Path - Image in the current project folder.
  • Absolute Path - Complete URL from the Internet.

Lab Practice

  1. Create an education details table.
  2. Create a student details table using colspan.
  3. Create a timetable using rowspan.
  4. Insert a local profile image.
  5. Insert an online image.
  6. Create a clickable image.

Summary