--- title: Panduan Borang HTML slug: Learn/Forms translation_of: Learn/Forms original_slug: Learn/HTML/Forms ---
Welcome to the Guide to HTML Forms. This guide is a series of articles that will help you master HTML Forms. HTML Forms are a very powerful tool to interact with a user; however, due to historical and technical reasons, it's not always obvious how you use them to their full potential. In this guide, we'll cover all aspects of HTML Forms, from structure to styling, from data handling to custom widgets. You'll learn to enjoy the great power they offer!
Element | Related DOM interface | Description |
---|---|---|
{{HTMLElement("button")}} | {{domxref("HTMLButtonElement")}} | The button element represents a clickable button. |
{{HTMLElement("datalist")}} | {{domxref("HTMLDataListElement")}} | The datalist element contains a set of {{ HTMLElement("option") }} elements that represent the possible options for the value of other forms elements. |
{{HTMLElement("fieldset")}} | {{domxref("HTMLFieldSetElement")}} | The fieldset is used to group several form elements within a form. |
{{HTMLElement("form")}} | {{domxref("HTMLFormElement")}} | The form element represents a section of document that contains interactive element that enable a user to submit information to a web server. |
{{HTMLElement("input")}} | {{domxref("HTMLInputElement")}} | The input element is used to create interactive controls for forms. |
{{HTMLElement("keygen")}} | {{domxref("HTMLKeygenElement")}} | The keygen element exists to facilitate generation of key material, and submission of the public key as part of an HTML form |
{{HTMLElement("label")}} | {{domxref("HTMLLabelElement")}} | The label element represents a caption for an item in a user interface |
{{HTMLElement("legend")}} | {{domxref("HTMLLegendElement")}} | The legend element represents a caption for the content of its parent {{ HTMLElement("fieldset") }}. |
{{HTMLElement("meter")}} | {{domxref("HTMLMeterElement")}} | The meter element represents either a scalar value within a known range or a fractional value. |
{{HTMLElement("optgroup")}} | {{domxref("HTMLOptGroupElement")}} | the optgroup element creates a group of options within a {{ HTMLElement("select") }} element. |
{{HTMLElement("option")}} | {{domxref("HTMLOptionElement")}} | the HTML option element is used to create a control representing an item within a {{ HTMLElement("select") }}, an {{ HTMLElement("optgroup") }} or a {{ HTMLElement("datalist") }} element. |
{{HTMLElement("output")}} | {{domxref("HTMLOutputElement")}} | The output element represents the result of a calculation. |
{{HTMLElement("progress")}} | {{domxref("HTMLProgressElement")}} | The progress element is used to view the completion progress of a task. |
{{HTMLElement("select")}} | {{domxref("HTMLSelectElement")}} | The select element represents a control that presents a menu of options. |
{{HTMLElement("textarea")}} | {{domxref("HTMLTextAreaElement")}} | The textarea element represents a multi-line plain-text editing control. |
Note: All form elements, as all HTML elements, support the {{domxref("HTMLElement")}} DOM interface.
Attribute Name | Elements | Description |
---|---|---|
accept | {{ HTMLElement("form") }}, {{ HTMLElement("input") }} | List of types the server accepts, typically a file type. |
accept-charset | {{ HTMLElement("form") }} | List of supported charsets. |
action | {{ HTMLElement("form") }} | The URI of a program that processes the information submitted via the form. |
autocomplete | {{ HTMLElement("form") }}, {{ HTMLElement("input") }} | Indicates whether controls in this form can by default have their values automatically completed by the browser. |
autofocus | {{ HTMLElement("button") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }} | The element should be automatically focused after the page loaded. |
challenge | {{ HTMLElement("keygen") }} | A challenge string that is submitted along with the public key. |
checked | {{ HTMLElement("input") }} | Indicates whether the element should be checked on page load. |
cols | {{ HTMLElement("textarea") }} | Defines the number of columns in a textarea. |
data | {{ HTMLElement("object") }} | Specifies the URL of the resource. |
dirname | {{ HTMLElement("input") }}, {{ HTMLElement("textarea") }} | |
disabled | {{ HTMLElement("button") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("optgroup") }}, {{ HTMLElement("option") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }} | Indicates whether the user can interact with the element. |
enctype | {{ HTMLElement("form") }} | Defines the content type of the form date when the method is POST. |
for | {{ HTMLElement("label") }}, {{ HTMLElement("output") }} | Describes elements which belongs to this one. |
form | {{ HTMLElement("button") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("label") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("object") }}, {{ HTMLElement("output") }}, {{ HTMLElement("progress") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }} | Indicates the form that is the owner of the element. |
high | {{ HTMLElement("meter") }} | Indicates the lower bound of the upper range. |
keytype | {{ HTMLElement("keygen") }} | Specifies the type of key generated. |
list | {{ HTMLElement("input") }} | Identifies a list of pre-defined options to suggest to the user. |
low | {{ HTMLElement("meter") }} | Indicates the upper bound of the lower range. |
max | {{ HTMLElement("input") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("progress") }} | Indicates the maximum value allowed. |
maxlength | {{ HTMLElement("input") }}, {{ HTMLElement("textarea") }} | Defines the maximum number of characters allowed in the element. |
method | {{ HTMLElement("form") }} | Defines which HTTP method to use when submitting the form. Can be GET (default) or POST. |
min | {{ HTMLElement("input") }}, {{ HTMLElement("meter") }} | Indicates the minimum value allowed. |
multiple | {{ HTMLElement("input") }}, {{ HTMLElement("select") }} | Indicates whether multiple values can be entered in an input of the type email or file . |
name | {{ HTMLElement("button") }}, {{ HTMLElement("form") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("output") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }} | Name of the element. For example used by the server to identify the fields in form submits. |
novalidate | {{ HTMLElement("form") }} | This attribute indicates that the form shouldn't be validated when submitted. |
optimum | {{ HTMLElement("meter") }} | Indicates the optimal numeric value. |
pattern | {{ HTMLElement("input") }} | Defines a regular expression which the element's value will be validated against. |
placeholder | {{ HTMLElement("input") }}, {{ HTMLElement("textarea") }} | Provides a hint to the user of what can be entered in the field. |
readonly | {{ HTMLElement("input") }}, {{ HTMLElement("textarea") }} | Indicates whether the element can be edited. |
required | {{ HTMLElement("input") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }} | Indicates whether this element is required to fill out or not. |
rows | {{ HTMLElement("textarea") }} | Defines the number of rows in a textarea. |
selected | {{ HTMLElement("option") }} | Defines a value which will be selected on page load. |
size | {{ HTMLElement("input") }}, {{ HTMLElement("select") }} | Defines the width of the element (in pixels). If the element's type attribute is text or password then it's the number of characters. |
src | {{ HTMLElement("input") }} | The URL of the embeddable content. |
step | {{ HTMLElement("input") }} | |
target | {{ HTMLElement("form") }} | |
type | {{ HTMLElement("button") }}, {{ HTMLElement("input") }} | Defines the type of the element. |
usemap | {{ HTMLElement("input") }} | |
value | {{ HTMLElement("button") }}, {{ HTMLElement("option") }}, {{ HTMLElement("input") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("progress") }} | Defines a default value which will be displayed in the element on page load. |
wrap | {{ HTMLElement("textarea") }} | Indicates whether the text should be wrapped. |