Web Unit 2
Web Unit 2
9. Summary
HTML tables are a powerful tool for displaying structured data. With the help of <table>, <tr>, <td>,
and <th> tags along with attributes like colspan, rowspan, and CSS styles, developers can create
visually appealing and accessible tables.
While tables should not be used for layout purposes in modern web development, they remain
essential for content that inherently fits into rows and columns.
1. Introduction
In HTML, tables are used to display data in a structured format with rows and columns. As tables
become more complex with many rows and columns, it becomes difficult to manage or style them
effectively.
To solve this issue, HTML provides a set of semantic tags that allow developers to group related
parts of a table into distinct sections. These are:
• <thead> – Groups the header content.
• <tbody> – Groups the main body content.
• <tfoot> – Groups the footer content.
These grouping tags help organize a table's structure both visually and logically, and enhance
readability, maintainability, and accessibility.
Feature Benefit
Semantic Clarity Easier for developers and screen readers to understand the table.
Better Styling Enables targeted CSS styling (e.g., background color for headers only).
Print Optimization Browsers may repeat <thead> across pages and move <tfoot> to top.
9. Accessibility Considerations
Grouping tags improve web accessibility, which is crucial for users who rely on assistive
technologies.
• <thead> tells the screen reader that this is a heading.
• <tfoot> helps summarize.
• Proper use of <th> within <thead> with the scope="col" or scope="row" attributes increases
accessibility.
Example:
<th scope="col">Product</th>
<th scope="col">Price</th>
These scope attributes specify how the header relates to the cell data, making navigation easier for
blind users.
Mistake Correction
Omitting <tbody> in dynamic tables Always include for scripting purposes
Using <thead> for non-header rows Use only for header content
12. Summary
HTML provides the grouping elements <thead>, <tbody>, and <tfoot> to logically organize tables
into sections. These help separate the table’s metadata from the main data and summary, making
tables:
• Easier to read
• Easier to style
• More accessible
• More responsive to printing and scripting
As modern web design moves toward semantic and accessible structures, using grouping tags in tables
is considered a best practice for all developers.
Nested Tables in HTML
1. Introduction
Tables in HTML are used to display data in a structured format using rows and columns. While simple
tables are easy to construct, sometimes the data representation requires tables within tables—this is
where nested tables come into play.
Nested Tables refer to placing one HTML <table> element inside another table's <td> (table data
cell) element. This allows developers to create complex table layouts and organize data hierarchically.
Benefit Description
Layout Flexibility Offers control over complex layouts (e.g., resumes, reports).
Point Explanation
Correct Nesting Always ensure tags like <table>, <tr>, and <td> are properly
closed.
Responsive Design Nested tables are hard to make responsive on small screens.
Limitation
12. Summary
Nested tables are a technique in HTML to place one table inside another for organizing complex or
hierarchical data. They provide flexibility but come with challenges like responsiveness and
readability.
Feature Description
9. Conclusion
Even without JavaScript, HTML tables are powerful tools for presenting structured data.
The concept of “accessing” tables in pure HTML involves:
• Organizing content using rows and columns
• Using semantic tags like <thead>, <tbody>, <tfoot>
• Enhancing clarity with <caption>, scope, and cell merging
• Improving layout with attributes like border, cellspacing, and cellpadding
Such well-structured tables allow for clear and logical access to data by both users and
assistive technologies. They form the foundation of data presentation in webpages, reports,
and dashboards.
<label for="email">Email:</label>
<input type="email" id="email" name="email"><br><br>
12. Conclusion
Forms are the backbone of interactive web pages. Whether it's for user registration, data
collection, or transactions, HTML forms allow websites to interact with users in a
structured way.
In summary:
• Forms are defined using <form> with action and method attributes.
• Various input types collect different kinds of data.
• Semantic and accessible forms enhance user experience.
• Attributes like required, placeholder, and autocomplete make forms more functional.
• HTML5 offers many enhancements for form validation and user-friendly design.
By understanding the structure and elements of HTML forms, developers can create
powerful, accessible, and responsive web forms that effectively gather and process user input.
6. Textarea: <textarea>
Used for multi-line input such as feedback, comments, or messages.
<textarea name="feedback" rows="5" cols="30" placeholder="Enter your
comments"></textarea>
Attributes:
• rows: Number of visible text lines
• cols: Width of the field
• maxlength: Limits number of characters
<label for="pwd">Password:</label>
<input type="password" id="pwd" name="password" required><br><br>
<label for="gender">Gender:</label>
<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female"> Female<br><br>
<label>Hobbies:</label>
<input type="checkbox" name="hobby" value="sports"> Sports
<input type="checkbox" name="hobby" value="reading"> Reading<br><br>
<label for="city">City:</label>
<select name="city">
<option value="erode">Erode</option>
<option value="chennai">Chennai</option>
</select><br><br>
12. Conclusion
HTML form controls are essential for gathering user input in structured and meaningful
ways. They support different types of data collection, from simple text to complex files and
dates.
In conclusion:
• Form controls allow interactive communication between user and website.
• There are multiple controls available for specific input types.
• HTML5 introduced new controls that reduce the need for scripts.
• Proper use of controls improves form design, usability, and accessibility.
Mastering form controls is vital for creating dynamic, user-friendly websites that gather
information accurately and efficiently.
1. Introduction
One of the main purposes of an HTML form is to collect data from the user and send it to a
server for processing. After the user fills out a form and submits it, the browser packages the
data and sends it to a specified location on the web server using the method and action
defined in the <form> tag.
Understanding how form data is sent to the server is essential in web development, as it is the
bridge between front-end input and back-end processing.
<label>Email:</label>
<input type="email" name="email" required><br><br>
<label>Password:</label>
<input type="password" name="password" required><br><br>
13. Conclusion
Sending form data to the server is a core part of web development that connects user input
with backend processing. Using the correct methods (GET, POST) and properly handling
data transmission ensures secure, reliable, and efficient web applications.
In summary:
• Use the <form> element with action and method.
• Choose GET for simple queries and POST for sensitive data.
• Form data is sent in name-value pairs.
• Server scripts receive, process, and respond to the data.
Mastering this process is essential for building interactive and data-driven websites.