HTML Day 4 Learning Material

Frames, IFrames and HTML Forms

Learning Outcomes

1. Frames

Frames divide a browser window into multiple sections, each displaying a different HTML page.

The <frameset> and <frame> tags were traditionally used to create frames.

Vertical Frames

<frameset cols="30%,70%">
    <frame src="menu.html">
    <frame src="content.html">
</frameset>

Horizontal Frames

<frameset rows="30%,70%">
    <frame src="top.html">
    <frame src="bottom.html">
</frameset>
Note: Frames are deprecated. HTML5 introduced the <iframe> tag as a modern replacement.

2. IFrame

The <iframe> (Inline Frame) embeds another webpage, document, map, video, PDF or other content inside the current webpage.

AttributePurpose
srcURL of content
widthIframe width
heightIframe height
titleAccessibility description
allowfullscreenEnable fullscreen videos

Syntax

<iframe src="page.html"></iframe>

Examples

<iframe src="about.html" width="500" height="300"></iframe>

<iframe src="https://www.example.com"
width="600" height="400"></iframe>

<iframe width="560" height="315"
src="https://www.youtube.com/embed/VIDEO_ID"></iframe>

<iframe src="GOOGLE_MAPS_EMBED_URL"
width="600" height="450"></iframe>

3. HTML Forms

Forms collect user input and send it to a web server for processing.

Syntax

<form action="" method="">
    ...
</form>

Form Attributes

AttributePurpose
actionDestination page
methodGET or POST
nameBackend reference name
requiredMakes field mandatory

GET vs POST

GETPOST
Visible in URLHidden from URL
Less secureMore secure
Limited dataLarge data
Default methodCommon for forms

4. Input Tag

The <input> tag is used to collect user input.

<input type="" name="" value="">

Common Input Types

Examples

Text Box

<input type="text" name="username">

Password

<input type="password" name="pwd">

Radio Button

<input type="radio" name="gender" value="Male"> Male
<input type="radio" name="gender" value="Female"> Female

Checkbox

<input type="checkbox" name="java"> Java
<input type="checkbox" name="python"> Python

Submit Button

<input type="submit" value="Submit">

Reset Button

<input type="reset" value="Reset">

Button

<input type="button" value="Click Me">

Dropdown

<select name="city">
    <option>Visakhapatnam</option>
    <option>Hyderabad</option>
    <option>Chennai</option>
</select>

Textarea

<textarea rows="4" cols="30">
Enter your address
</textarea>

5. HTML Input Type Reference

Input TypePurposeExample
textSingle-line text<input type="text">
passwordPassword<input type="password">
emailEmail<input type="email">
telPhone<input type="tel">
dateDate picker<input type="date">
timeTime picker<input type="time">
datetime-localDate & Time<input type="datetime-local">
numberNumeric<input type="number">
urlWebsite<input type="url">
searchSearch<input type="search">
fileUpload<input type="file">
radioRadio<input type="radio">
checkboxCheckbox<input type="checkbox">
submitSubmit<input type="submit">
resetReset<input type="reset">
buttonButton<input type="button">
colorColor Picker<input type="color">
rangeSlider<input type="range">
Tip: Prefer HTML5 input types such as email, tel, date, color and range to improve validation and user experience.