Module -1 | Day 4

Day 4: HTML Lists and Tables

Day 4: HTML Lists and Tables

HTML Lists and Tables

Inn nammalk HTML lists'um tables'um padikkan pokunnu.

HTML Lists

Creating Ordered and Unordered Lists

HTML provides two types of lists: ordered lists and unordered lists.

Unordered Lists

An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.


<ul>
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
</ul>
            

Example:

  • Item 1
  • Item 2
  • Item 3
Ordered Lists

An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.


<ol>
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
</ol>
            

Example:

  1. Item 1
  2. Item 2
  3. Item 3

Creating Tables with Rows and Columns

HTML tables are created with the <table> tag. Tables are divided into rows with the <tr> tag, and each row is divided into data cells with the <td> tag. Table headers are defined with the <th> tag.


<table>
    <tr>
        <th>Header 1</th>
        <th>Header 2</th>
    </tr>
    <tr>
        <td>Data 1</td>
        <td>Data 2</td>
    </tr>
    <tr>
        <td>Data 3</td>
        <td>Data 4</td>
    </tr>
</table>
            

Example:

Header 1 Header 2
Data 1 Data 2
Data 3 Data 4

Put It Together

Let's combine what we've learned about lists and tables into a single example.


    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>HTML Lists and Tables Example</title>
    </head>
    <body>
        <h1>Lists and Tables</h1>

        <h2>Unordered List</h2>
        <ul>
            <li>Item 1</li>
            <li>Item 2</li>
            <li>Item 3</li>
        </ul>

        <h2>Ordered List</h2>
        <ol>
            <li>Item 1</li>
            <li>Item 2</li>
            <li>Item 3</li>
        </ol>

        <h2>Table</h2>
        <table border="1">
            <tr>
                <th>Header 1</th>
                <th>Header 2</th>
            </tr>
            <tr>
                <td>Data 1</td>
                <td>Data 2</td>
            </tr>
            <tr>
                <td>Data 3</td>
                <td>Data 4</td>
            </tr>
        </table>
    </body>

result





    
    
    HTML Lists and Tables Example


    

Lists and Tables

Unordered List

  • Item 1
  • Item 2
  • Item 3

Ordered List

  1. Item 1
  2. Item 2
  3. Item 3

Table

Header 1 Header 2
Data 1 Data 2
Data 3 Data 4

Summary

Today, we've covered:

  • Creating Ordered and Unordered Lists: Learned how to create lists using the <ul> and <ol> tags with <li> for list items.
  • Creating Tables: Learned how to create tables using the <table>, <tr>, <th>, and <td> tags.

Practice Exercise

Try creating a simple webpage that includes the following:

  • An unordered list with three items.
  • An ordered list with three items.
  • A table with two columns and three rows.

Let's try this project

Project name

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>3D Music Player</title>
    <style>
        body {
            background-color: #1e1e1e;
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            color: #fff;
        }
        .player-container {
            background-color: #333;
            border-radius: 15px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
            padding: 20px;
            text-align: center;
            width: 350px;
        }
        .record {
            position: relative;
            width: 200px;
            height: 200px;
            margin: 20px auto;
            border-radius: 50%;
            background: url('https://i.imghippo.com/files/VxHkd1720541003.jpg') no-repeat center center/cover;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
            animation: spin 5s linear infinite;
        }
        .tonearm {
            position: absolute;
            width: 50px;
            height: 120px;
            top: 20px;
            left: 160px;
            background-color: #009AFF;
            border-radius: 50px;
            transform-origin: top left;
            animation: tonearm-move 5s linear infinite;
        }
        @keyframes spin {
            from {
                transform: rotate(0deg);
            }
            to {
                transform: rotate(360deg);
            }
        }
        @keyframes tonearm-move {
            0%, 50%, 100% {
                transform: rotate(-30deg);
            }
            25%, 75% {
                transform: rotate(-10deg);
            }
        }
        .controls {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 10px;
            margin-top: 20px;
        }
        .controls button {
            background-color: #FFFFFF;
            border: none;
            border-radius: 50%;
            color: #fff;
            cursor: pointer;
            font-size: 20px;
            height: 50px;
            width: 50px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
            transition: background-color 0.3s;
        }
        .controls button:hover {
            background-color: #3700b3;
        }
        .progress-bar {
            width: 100%;
            height: 5px;
            background-color: #e0e0e0;
            border-radius: 5px;
            margin-top: 20px;
            position: relative;
        }
        .progress {
            width: 0;
            height: 100%;
            background-color: #6200ea;
            border-radius: 5px;
            transition: width 0.3s;
        }
    </style>
</head>
<body>
    <div class="player-container">
        <h2>Music Player - NiLBiTE</h2>
        <p>Despacito - Luis Fonsi ft. Daddy Yankee</p>
        <div class="record">
            <div class="tonearm"></div>
        </div>
        <div class="controls">
            <button id="prev">⏮️</button>
            <button id="play-pause">⏯️</button>
            <button id="next">⏭️</button>
        </div>
        <div class="progress-bar">
            <div class="progress" id="progress"></div>
        </div>
        <audio id="audio" src="https://cdn.trendybeatz.com/audio/Luis-Fonsi-Ft-Daddy-Yankee-Despacito-(TrendyBeatz.com).mp3"></audio>
    </div>

    <script>
        const audio = document.getElementById('audio');
        const playPauseButton = document.getElementById('play-pause');
        const record = document.querySelector('.record');
        const progressBar = document.getElementById('progress');

        let isPlaying = false;

        playPauseButton.addEventListener('click', () => {
            if (isPlaying) {
                audio.pause();
                record.style.animationPlayState = 'paused';
                playPauseButton.textContent = '▶️';
            } else {
                audio.play();
                record.style.animationPlayState = 'running';
                playPauseButton.textContent = '⏸️';
            }
            isPlaying = !isPlaying;
        });

        audio.addEventListener('timeupdate', () => {
            const progressPercent = (audio.currentTime / audio.duration) * 100;
            progressBar.style.width = `${progressPercent}%`;
        });

        audio.addEventListener('ended', () => {
            record.style.animationPlayState = 'paused';
            playPauseButton.textContent = '▶️';
            isPlaying = false;
        });
    </script>
</body>
</html>

Result look like this