Button
Simple Button
The <button>
element creates a clickable button in HTML. It can contain text or other HTML elements and is commonly used to perform actions like submitting forms or executing scripts.
<button type="button">Click Here</button>
Submit Form Button
The <button type="submit">
element is used within a form to send input data to the server when clicked.
<form>
<label for="ename">Enter Name:</label>
<input id="ename" type="text" name="ename" /><br />
<button type="submit">Submit</button>
</form>
Reset Form Button
The <button type="reset">
element clears all form fields, returning them to their initial values. It allows users to reset input fields easily.
<form>
<label for="ename">Enter Name:</label>
<input id="ename" type="text" name="ename" /><br />
<button type="reset">Reset</button>
</form>
Key Attributes
autofocus
– Automatically focuses on the button when the page loads.disabled
– Disables the button, preventing user interaction.form
– Links the button to a specific form.formaction
– Defines the URL where form data should be sent.formmethod
– Specifies the HTTP method for form submission (GET
orPOST
).formenctype
– Determines how form data should be encoded.name
– Assigns a name to the button for form processing.type
– Specifies the button's function (button
,submit
, orreset
).value
– Defines a value associated with the button.
Global & Event Attributes
The <button>
element supports all global and event attributes in HTML.
Conclusion
The <button>
element in HTML is used to create clickable buttons for various functions, such as triggering actions, submitting forms, or resetting input fields. Different button types include type="button"
, type="submit"
, and type="reset"
, each serving a specific purpose.
Language Codes
HTML language codes, specified by the lang attribute, indicate the language of the content, helping browsers and search engines display and interpret it correctly.
Iframes
An HTML <iframe> allows you to embed another web page within the current page. You can adjust its size and content using attributes like src, width, and height.