HTML Frames and Forms
1. HTML Frames
HTML frames are used to divide a web page into multiple sections, where each section can load a different
document.
Frames are created using the <frameset> tag.
1.1 Frame Structure
The <frameset> tag replaces <body> in older HTML versions (mainly HTML 4).
Each <frame> tag defines a separate section within the frameset.
Example Code:
<frameset cols="30%, 70%">
<frame src="menu.html">
<frame src="content.html">
</frameset>
1.2 Attributes for <frameset>
Attribute Description
cols Divides the page into vertical columns.
rows Divides the page into horizontal rows.
border Defines the border size between frames.
1.3 Attributes for <frame>
Attribute Description
src Specifies the URL of the document to load.
name Assigns a name to the frame for targeting links.
scrolling Controls scrollbars (yes, no, auto).
noresize Prevents the frame from being resized.
Example with Rows:
<frameset rows="50%, 50%">
<frame src="header.html">
<frame src="footer.html">
</frameset>
Note: HTML5 no longer supports <frameset> and <frame>. Use CSS Flexbox or CSS Grid for modern
layouts.
2. HTML Forms
HTML forms allow users to enter data that can be sent to a web server.
2.1 Basic Structure of a Form
<form action="/submit-form" method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<input type="submit" value="Submit">
</form>
2.2 Common Form Elements
Element Description
<input> Collects user data (text, password, etc.).
<textarea> Creates multi-line text input.
<select> Provides dropdown options.
<button> Submits or resets the form.
<label> Provides a label for each form field.
2.3 Form Attributes
Attribute Description
action Defines the URL where form data will be sent.
method Defines the HTTP method: GET (visible in URL) or POST (more secure).
name Identifies form elements for processing.
2.4 Input Types
Type Description
text Single-line text input.
password Hidden text input for passwords.
email Validates email format.
radio Select one option from a group.
checkbox Select multiple options.
submit Submits the form.
reset Clears all inputs.
Example with Dropdown List:
<form>
<label for="country">Choose a country:</label>
<select id="country" name="country">
<option value="usa">USA</option>
<option value="canada">Canada</option>
</select>
<input type="submit" value="Submit">
</form>
Conclusion:
- HTML frames are outdated but useful for legacy projects.
- HTML forms are essential for collecting user data efficiently.