W3Schools.com (2024)


Example

An HTML form with two input fields and one submit button:

<form action="/action_page.php" method="get">
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname"><br><br>
<input type="submit" value="Submit">
</form>

Try it Yourself »

More "Try it Yourself" examples below.

Definition and Usage

The <form> tag is used to create an HTML form for user input.

The <form> element can contain one or more of the following form elements:

Browser Support

Element
<form> Yes Yes Yes Yes Yes

Attributes

Attribute Value Description
accept-charset character_set Specifies the character encodings that are to be used for the form submission
action URL Specifies where to send the form-data when a form is submitted
autocomplete on
off
Specifies whether a form should have autocomplete on or off
enctype application/x-www-form-urlencoded
multipart/form-data
text/plain
Specifies how the form-data should be encoded when submitting it to the server (only for method="post")
method get
post
Specifies the HTTP method to use when sending form-data
name text Specifies the name of a form
novalidate novalidate Specifies that the form should not be validated when submitted
rel external
help
license
next
nofollow
noopener
noreferrer
opener
prev
search
Specifies the relationship between a linked resource and the current document
target _blank
_self
_parent
_top
Specifies where to display the response that is received after submitting the form

Global Attributes

The <form> tag also supports the Global Attributes in HTML.

Event Attributes

The <form> tag also supports the Event Attributes in HTML.

More Examples

Example

An HTML form with checkboxes:

<form action="/action_page.php" method="get">
<input type="checkbox" name="vehicle1" value="Bike">
<label for="vehicle1"> I have a bike</label><br>
<input type="checkbox" name="vehicle2" value="Car">
<label for="vehicle2"> I have a car</label><br>
<input type="checkbox" name="vehicle3" value="Boat" checked>
<label for="vehicle3"> I have a boat</label><br><br>
<input type="submit" value="Submit">
</form>

Try it Yourself »

Example

An HTML form with radiobuttons:

<form action="/action_page.php" method="get">
<input type="radio" id="html" name="fav_language" value="HTML">
<label for="html">HTML</label><br>
<input type="radio" id="css" name="fav_language" value="CSS" checked="checked">
<label for="css">CSS</label><br>
<input type="radio" id="javascript" name="fav_language" value="JavaScript">
<label for="javascript">JavaScript</label><br><br>
<input type="submit" value="Submit">
</form>

Try it Yourself »

Related Pages

HTML tutorial: HTML Forms and Input

HTML DOM reference: Form Object

CSS Tutorial: Styling Forms

Default CSS Settings

Most browsers will display the <form> element with the following default values:

Example

form {
display: block;
margin-top: 0em;
}

Try it Yourself »

W3schools Pathfinder

Track your progress - it's free!

W3Schools.com (2024)
Top Articles
Breakouts and fakeouts
How do I withdraw funds to my bank account?
The Tribes and Castes of the Central Provinces of India, Volume 3
Lakers Game Summary
Cintas Pay Bill
Booknet.com Contract Marriage 2
Celsius Energy Drink Wo Kaufen
Azeroth Pilot Reloaded - Addons - World of Warcraft
Simple Steamed Purple Sweet Potatoes
Https //Advanceautoparts.4Myrebate.com
Leeks — A Dirty Little Secret (Ingredient)
finaint.com
Nutrislice Menus
Las 12 mejores subastas de carros en Los Ángeles, California - Gossip Vehiculos
1v1.LOL - Play Free Online | Spatial
Persona 4 Golden Taotie Fusion Calculator
Ratchet & Clank Future: Tools of Destruction
Bible Gateway passage: Revelation 3 - New Living Translation
Boscov's Bus Trips
Hannaford To-Go: Grocery Curbside Pickup
3Movierulz
The 15 Best Sites to Watch Movies for Free (Legally!)
Milwaukee Nickname Crossword Clue
Geico Car Insurance Review 2024
Great ATV Riding Tips for Beginners
2004 Honda Odyssey Firing Order
Shiny Flower Belinda
Login.castlebranch.com
Cinema | Düsseldorfer Filmkunstkinos
Ff14 Sage Stat Priority
Publix Daily Soup Menu
Rust Belt Revival Auctions
Southern Democrat vs. MAGA Republican: Why NC governor race is a defining contest for 2024
Nsu Occupational Therapy Prerequisites
Trebuchet Gizmo Answer Key
Craigslist Lakeside Az
Pitchfork's Top 200 of the 2010s: 50-1 (clips)
Are you ready for some football? Zag Alum Justin Lange Forges Career in NFL
Soulstone Survivors Igg
Überblick zum Barotrauma - Überblick zum Barotrauma - MSD Manual Profi-Ausgabe
Pa Legion Baseball
Trivago Anaheim California
Ds Cuts Saugus
60 Days From May 31
Candise Yang Acupuncture
Movie Hax
Dancing Bear - House Party! ID ? Brunette in hardcore action
ESPN's New Standalone Streaming Service Will Be Available Through Disney+ In 2025
WHAT WE CAN DO | Arizona Tile
Gameplay Clarkston
Koniec veľkorysých plánov. Prestížna LEAF Academy mení adresu, masívny kampus nepostaví
Latest Posts
Article information

Author: Sen. Emmett Berge

Last Updated:

Views: 5641

Rating: 5 / 5 (60 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Sen. Emmett Berge

Birthday: 1993-06-17

Address: 787 Elvis Divide, Port Brice, OH 24507-6802

Phone: +9779049645255

Job: Senior Healthcare Specialist

Hobby: Cycling, Model building, Kitesurfing, Origami, Lapidary, Dance, Basketball

Introduction: My name is Sen. Emmett Berge, I am a funny, vast, charming, courageous, enthusiastic, jolly, famous person who loves writing and wants to share my knowledge and understanding with you.