Creating a Simple Student Registration Form using HTML Tables

Creating a Simple Student Registration Form using HTML Tables
Creating a Simple Student Registration Form using HTML Tables

Introduction

Providing an intuitive layout and design for users is essential when creating a web-based form. HTML tables are one way to organize and structure your form in a neat and easy-to-read manner. In this blog post, we’ll walk you through the process of creating a simple student registration form using HTML tables.

Also, check out How to Create Registration Form in HTML – Easy

And How to make Password Reset System using Php?

Step 1: Set Up the HTML Document Structure

To begin, create a new HTML file and set up the basic structure of an HTML document. Add a suitable title, and include any necessary CSS or JavaScript files if needed.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Student Registration Form</title>
    <!-- Add your CSS and JavaScript files here -->
</head>
<body>
    <!-- Your form will be placed here -->
</body>
</html>

Step 2: Create the Student Registration Form

Inside the <body> tags, start by creating an <form> element with the necessary attributes (such as action and method). Then, create an <table> the element inside the form to structure the input fields and labels.

<form action="your-action-url" method="POST">
    <table>
        <!-- Form content will be placed here -->
    </table>
</form>

Step 3: Add Form Content with Table Rows and Cells

Now, let’s add the form content using table rows (<tr>) and cells (<td>). Each input field and its corresponding label will be placed within a separate cell. You can also include a header row to give the form a title.

<form action="your-action-url" method="POST">
    <table>
        <tr>
            <th colspan="2">Student Registration Form</th>
        </tr>
        <tr>
            <td>First Name:</td>
            <td><input type="text" name="first_name" required></td>
        </tr>
        <tr>
            <td>Last Name:</td>
            <td><input type="text" name="last_name" required></td>
        </tr>
        <tr>
            <td>Email:</td>
            <td><input type="email" name="email" required></td>
        </tr>
        <tr>
            <td>Phone Number:</td>
            <td><input type="tel" name="phone_number" required></td>
        </tr>
        <tr>
            <td>Course:</td>
            <td>
                <select name="course" required>
                    <option value="">Select Course</option>
                    <option value="Computer Science">Computer Science</option>
                    <option value="Mathematics">Mathematics</option>
                    <option value="Physics">Physics</option>
                </select>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="submit" value="Register">
            </td>
        </tr>
    </table>
</form>

Step 4: Style the Form (Optional)

You may want to add some CSS to style the form and make it visually appealing. For example, you can add basic styling to the table, form elements, and buttons.

<head>
    <!-- Other head content -->
    <style>
        table {
            width: 50%;
            margin: 0 auto;
            border-collapse: collapse;
        }

        th, td {
            border: 1px solid #ccc;
            padding: 10px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
            font-weight: bold;
        }

        input[type="text"],
        input[type="email"],
        input[type="tel"],
        select {
            width: 100%;
            padding: 5px;
            margin: 2px 0;
            display: inline-block;
            border: 1px solid #ccc;
            box-sizing: border-box;
        }

        input[type="submit"] {
            background-color: #4CAF50;
            color: white;
            padding: 10px 20px;
            margin: 8px 0;
            border: none;
            cursor: pointer;
            width: 100%;
         }

        input[type="submit"]:hover {
            background-color: #45a049;
        }
    </style>
</head>

Conclusion:

In this blog post, we demonstrated how to create a simple student registration form using HTML tables. By organizing form elements with tables, you can create a structured and easy-to-read layout for your users. You can further enhance the form by adding custom styles and validating the input data with JavaScript. Don’t forget to replace the “your-action-url” attribute in the form tag with the URL where you want to process the submitted form data.

You can find the source code here on GitHub.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments