HTML Forms (1)
HTML Forms (1)
HTML FORMS
Used to collect the user information
There are different types to use the input field
Maximum , the forms are used to register and receiving the
details
Collect the information such as name, password,
email address, number etc
There are various form elements like textarea fields, text fields,
drop-down menus, Radio button , checkbox etc.
FORM ELEMENTS
• Button • range
• Checkbox • reset
• search • submit
• Date • tel
• Datetime-local • text
• Email • time
• Image • url
• Month • week
• Number
• Password
• radio
Button
Syntax :
<body>
<h2>Submit Button</h2>
<form>
<label>Username: <input type="text" /></label>
<label>Password: <input type="password" /></label>
<button type="submit“ >submit</button>
</form>
</body>
Checkbox
Syntax :
<body>
<h2>Checkbox field</h2>
<form>
<input type="checkbox" />
data1 checkbox <br>
<input type="checkbox"/>
data2 checkbox <br>
<input type="checkbox"/>
data3 checkbox
</form>
</body>
search
Syntax:
<body>
<h2>Search field</h2>
<form>
<label for=“gsearch”>Search : </label>
<input type=“search” id=“gsearch” name=“search”>
<input type=“submit”>
</form>
</body>
Date
Syntax:
<body>
<h2> date field</h2>
<p>it is used to date picker to the element</p>
<form action="/action_page.php">
<label for="birthday">Birthday:</label>
<input type="date" id="birthday" name="birthday">
<input type="submit">
</form>
<body>
Datetime- local
• It defined as the date picker
• It includes day, month, year and time
Syntax:
<body>
<h2> datetime-local field</h2>
<p>it is used to date picker to the element</p>
<form action="/action_page.php">
<label for="birthdaytime">Birthday:</label>
<input type="datetime-local" id="birthdaytime"
name="birthdaytime">
<input type="submit">
</form>
<body>
Email field
Syntax:
<body>
<h2> datetime-local field</h2>
<h3>Show an email field </h3>
<form action="/action_page.php">
<label for="email">Enter your email:</label>
<input type="email" id="email" name="email">
<input type="submit">
</form>
<h3>multiple email</h3>
<form action="/action_page.php">
<label for="emails">Enter email addresses:</label>
<input type="email" id="emails" name="emails" multiple>
<input type="submit">
</form>
</body>
Image field
Syntax:
<body>
<h2> image field</h2>
<form action="/action_page.php">
First name:
<input type="text" id="fname" name="fname">
<br><br>
<input type="image" src="submit.png" alt="Submit" width="100" height="50">
</form>
</body>
Month field
Syntax:
<body>
<h2> month field</h2>
<form action="/action_page.php">
<label for="month">Month :</label>
<input type="month" id="month" name="month">
<input type="submit">
</form>
</body>
Number
Syntax:
<body>
<h2> Number field</h2>
<form action="/action_page.php">
<label >number :</label>
<input type="number" name="quantity" min="1" max="5">
<input type="submit">
</form>
</body>
Radio
Syntax:
<body>
<h2> Radio field</h2>
<form action="/action_page.php">
<p>Select option:</p>
<input type="radio" >
<label >Tamil</label><br>
<input type="radio" >
<label >English</label><br>
<input type="radio" >
<label >Hindi</label>
</form>
</body>
Range
Syntax:
<body>
<h2> Range field</h2>
<form action="/action_page.php">
<label for="vol">Volume (between 0 and 50):</label>
<input type="range" min="0" max="50"><br> <br>
<input type="submit">
</form>
</body>
Reset
• Reset button, resets all the form values that already filled
Syntax :
<body>
<h2> Reset field</h2>
<form action="/action_page.php">
Name:
<input type="text" ><br><br>
Age
<input type="number"><br><br>
<input type="reset" value="Reset">
<input type="submit" value="Submit">
</form>
</body>
Submit
Syntax:
<body>
<h2> Reset field</h2>
<form action="/action_page.php">
Name:
<input type="text" ><br><br>
Age
<input type="number"><br><br>
<input type="submit" value="Submit">
</form>
</body>
tel
Syntax:
<body>
<h2> tell field</h2>
<form action="/action_page.php">
<label for="phone">Enter a phone number:</label>
<br><br>
<input type="tel" id="phone" name="phone“
placeholder="123-45-678"
pattern="[0-9]{3}-[0-9]{2}-[0-9]{3}" required>
<br><br>
<input type="submit">
</form>
</body>
Text
Syntax:
<body>
<h2> Text field</h2>
<form action="/action_page.php">
Name:
<input type="text" >
<input type="submit" value="Submit">
</form>
</body>
Time
Syntax:
<body>
<h2> Text field</h2>
<form action="/action_page.php">
Name:
<input type="time" ><br><br>
<input type="submit" value="Submit“>
</form>
</body>
url
Syntax:
<body>
<h2> URL field</h2>
<form action="/action_page.php">
My URL:
<input type="url" ><br><br>
<input type="submit" value="Submit">
</form>
</body>
Week
Syntax :
<body>
<h2> Week field</h2>
<form action="/action_page.php">
Task week:
<input type="week" ><br><br>
<input type="submit" value="Submit">
</form>
</body>
HTML LAYOUT
AND RESPONSIVE
HTML LAYOUT
In inline media :
media=“(max-width:__px)”
In external media: