Paramclasses Academy - Blog

Tutorials Details

Interactive Student Grades Overview: Building a Responsive Table with HTML and CSS

Interactive Student Grades Overview: Building a Responsive Table with HTML and CSS

October 17, 2024

1. HTML (table.html)

Stylish Table using HTML and CSS

Student Grades

Name Mathematics Science English History Geography Grade Status
Anuradha A B A A B A Pass
Devendra B C B A C B Pass
Nikhil C A B C A B Pass
Roshan Dev D D C B D C Fail
Sushmita B A A A A A Pass
Pooja C B A D B B Pass
Gouri A A B A C A Pass
Heena B B C B A B Pass
Imran A C B A B A Pass

2. CSS (style.css) * { margin: 0; padding: 0; box-sizing: border-box; } body { display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #f4f4f4; font-family: Arial, sans-serif; } .table-container { width: 90%; max-width: 800px; background-color: #fff; padding: 20px; border-radius: 8px; box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1); } h2 { text-align: center; margin-bottom: 20px; } table { width: 100%; border-collapse: collapse; } th, td { padding: 10px; text-align: left; border: 1px solid #ddd; } th { background-color: #4CAF50; color: white; } tr:nth-child(even) { background-color: #f2f2f2; } tr:hover { background-color: #ddd; } Explanation: HTML: A. Table Structure: 1. The table is wrapped in a div with the class table-container. 2. It includes a heading (

) and a element. 3. The table has a header section () and a body section (). 4. Each row of the table consists of elements, containing header cells (

) in the header and data cells ( ) in the body. CSS: A. Layout and Centering: 1. The body uses Flexbox to center the table container on the page. 2. The table container has a white background, padding, rounded corners, and a subtle shadow. B. Table Styling: 1. The table takes up the full width of its container, and border-collapse: collapse; ensures that borders between cells are combined. 2. Padding is applied to both table headers ( ) and data cells ( ), with a light border around each cell. 3. Header Styling: 4. The header cells have a green background (#4CAF50) and white text for contrast. C. Row Styling: 1. Every even row of the table has a light grey background color to enhance readability. 2. The :hover effect changes the background color of a row when hovered over, providing a nice visual effect.

Copyright © Paramwebinfo Academy.All Rights Reserved

Designed by PARAMWEBINFO