HTML Form Code

You can use the following HTML code to create a form within your HTML document. Note that this also includes table code for formatting purposes.

You can also check out the HTML Forms page of the HTML Tutorial.

Example HTML Form Code:

CodeResult

Your Details



Pasta Fish

Beer Wine


Templates

The form tags contain other tags nested within them. These other tags define the actual form elements that appear within the form.

You can use the following template as a basis for your HTML form codes. Simply fill in the blanks or remove uneeded attributes.

Since HTML form code is made up of several tags, each tag is presented separately here.

1. The <form> Tag

For an explanation of all the attributes, see the HTML form tag specifications.

<form
	action=""
	method=""
	enctype=""
	accept-charset=""
	accept=""
	name=""
	class=""
	id=""
	dir=""
	lang=""
	target=""
	onSubmit=""
	onReset=""
	onclick=""
	ondbclick=""
	onmousedown=""
	onmouseup=""
	onmouseover=""
	onmousemove=""
	onmouseout=""
	onkeypress=""
	onkeydown=""
	onkeyup="" >

	(the individual form element tags go here - see below)

	</form>

2. The <input> Tag

This tag defines input fields within the form.

For an explanation of all the attributes, see the HTML input tag specifications.

<input
	type=""
	name=""
	value=""
	size=""
	maxlength=""
	checked=""
	src=""
	class=""
	id=""
	dir=""
	lang=""
	title=""
	style=""
	align=""
	alt=""
	readonly=""
	disabled=""
	tabindex=""
	accesskey=""
	ismap=""
	usemap=""
	onfocus=""
	onblur=""
	onselect=""
	onchange=""
	onclick=""
	ondbclick=""
	onmousedown=""
	onmouseup=""
	onmouseover=""
	onmousemove=""
	onmouseout=""
	onkeypress=""
	onkeydown=""
	onkeyup="" />

3. The <select> Tag

This tag defines a dropdown menu within the form. This works in conjunction with the <option> tag.

For an explanation of all the attributes, see the HTML select tag specifications.

<select
	name=""
	size=""
	multiple=""
	class=""
	id=""
	dir=""
	lang=""
	style=""
	title=""
	tabindex=""
	disabled=""
	onclick=""
	ondbclick=""
	onmousedown=""
	onmouseup=""
	onmouseover=""
	onmousemove=""
	onmouseout=""
	onkeypress=""
	onkeydown=""
	onkeyup=""
>

(option tags go here for each item you need in your list)

<select/>

4. The <option> Tag

This tag defines an item within a dropdown menu. This works in conjunction with the <select> tag.

For an explanation of all the attributes, see the HTML option tag specifications.

<option
	selected=""
	value=""
	label=""
	class=""
	id=""
	dir=""
	lang=""
	style=""
	title=""
	tabindex=""
	disabled=""
	onclick=""
	ondbclick=""
	onmousedown=""
	onmouseup=""
	onmouseover=""
	onmousemove=""
	onmouseout=""
	onkeypress=""
	onkeydown=""
	onkeyup=""
>

(list item goes here)

</option>

5. The <textarea> Tag

This tag defines a text area within the form.

For an explanation of all the attributes, see the HTML textarea tag specifications.

<textarea
	name=""
	rows=""
	cols=""
	class=""
	id=""
	dir=""
	lang=""
	title=""
	style=""
	readonly=""
	disabled=""
	tabindex=""
	onfocus=""
	onblur=""
	onselect=""
	onchange=""
	onclick=""
	ondbclick=""
	onmousedown=""
	onmouseup=""
	onmouseover=""
	onmousemove=""
	onmouseout=""
	onkeypress=""
	onkeydown=""
	onkeyup="" >

	(this is where the user can type stuff)

</textarea>

Enjoy this page?

  1. Link to this page (copy/paste into your own website or blog):
  2. Link to Quackit using one of these banner ads.

Thanks for supporting Quackit!

Sponsored Link: Design CODE-FREE Websites

Check a Domain:

ZappyHost Logo
Webydo Banner Ad
Webydo Banner Ad