Skip to content
  • Quizes
  • QStack
  • Blog
  • pinterest
  • instagram
  • twitter
  • linkedin
  • facebook
W3 Coding Schools
  • Home
  • HTML
    • HTML Introduction
    • HTML Editors
    • Fundamentals of HTML
    • Elements of HTML
    • HTML Attributes
    • HTML Headings
    • HTML Paragraphs
    • HTML Style Attribute
    • HTML Text Formatting
    • HTML Phrase Tags
    • HTML Comments
    • HTML with CSS
    • HTML Links
    • HTML Images
    • HTML Tables
    • HTML Lists
    • HTML Blocks
    • HTML Class Attribute
    • HTML Id Attribute
    • HTML Iframes
    • HTML JavaScript
    • HTML File Paths
    • HTML Head
    • Computer Code Elements
    • HTML Entities
    • HTML Charset
    • HTML URL Encode
    • HTML and XHTML
    • HTML Layouts
    • HTML Forms
    • HTML Form Elements
    • HTML Form Input Types
    • HTML Input Attributes
    • HTML5 Introduction
    • HTML5 New Elements
    • Semantic Elements
    • HTML5 Migration
    • Style Guide
    • HTML Canvas
  • CSS
    • CSS Introduction
    • CSS Syntax and CSS Comments
    • CSS Selectors
    • How to add CSS to a Webpage
    • CSS Color Basics
    • CSS Background Properties
    • CSS Border Properties
    • CSS Margin and Padding Properties
    • CSS Height and Width properties
    • CSS Box Model
    • CSS Outline Properties
    • CSS Fonts
    • CSS Text
    • How To Add Icons
    • CSS Links
    • CSS List-Style
    • CSS Tables
    • CSS Display Property
    • CSS Position Property
    • CSS Overflow Property
    • CSS max-width Property
    • CSS Float and Clear Properties
    • CSS Alignment
    • CSS inline-block
    • CSS Combinators
    • CSS Pseudo Classes
    • CSS Pseudo Elements
    • CSS Opacity
    • CSS Navigation Bar
    • CSS Dropdowns
    • CSS Image Gallery
    • CSS Image Sprites
    • CSS Attribute Selector
    • CSS Styling Forms
    • CSS Counters
    • CSS Units
    • CSS Specificity
    • CSS Website Layout
    • CSS Rounded Corners
    • CSS Border Image Property
    • CSS Multiple Backgrounds
    • CSS Gradient
    • CSS Shadow Effects
    • CSS Text Effects
    • CSS Web Fonts
    • CSS 2D Transforms
  • Bootstrap 4
    • Bootstrap 4 – Introduction
    • Bootstrap versions
    • Bootstrap 4 Layout
    • Bootstrap 3 Vs Bootstrap 4
    • Bootstrap 4 Grid System
    • Bootstrap 4 Typography
    • Bootstrap 4 Colors
    • Bootstrap 4 Images
    • Bootstrap 4 Tables
    • Bootstrap 4 Jumbotron
    • Bootstrap 4 Figures
    • Bootstrap 4 Alerts
    • Bootstrap 4 Buttons
    • Bootstrap 4 Button Group
    • Bootstrap 4 Badges
    • Bootstrap 4 Spinners
    • Bootstrap 4 Progress Bars
    • Bootstrap 4 Pagination
    • Bootstrap 4 Breadcrumbs
    • Bootstrap 4 List Groups
    • Bootstrap 4 Cards
  • jQuery
    • jQuery Introduction
    • jQuery Download
    • jQuery Selectors
    • jQuery Event Methods
    • jQuery Hide/Show Effects
    • jQuery Fading Effects
    • jQuery Sliding Effects
    • jQuery Animation
    • jQuery Stop and Callback
    • jQuery Get and Set Methods
    • jQuery Chaining
    • jQuery Add
    • jQuery Remove
    • jQuery CSS Classes
    • jQuery Style Properties
    • jQuery Dimensions
    • jQuery Traversing
    • jQuery Ancestors
    • jQuery Descendants
    • jQuery Siblings
  • Javascript
    • JS Introduction
    • JS Where to Put
    • JavaScript Syntax
    • JavaScript Comments
    • JavaScript Variables
    • JavaScript Data Types
    • JavaScript Operators
    • JavaScript Events
    • JavaScript Strings
    • JavaScript Numbers
  • php
    • PHP Introduction
    • Install PHP
    • PHP Syntax and Comments
    • PHP Variables
    • PHP Constants
    • PHP Echo and Print
    • PHP Data Types
    • PHP Strings
    • PHP Operators
    • PHP $ and $$ Variables
  • WordPress
    • WordPress Introduction
    • WordPress History
    • WordPress.com vs WordPress.org
    • How to Install WordPress
    • WordPress Dashboard
    • How to Create a WordPress Website
    • WordPress Posts
    • WordPress Pages
    • WordPress Posts vs Pages
    • WordPress Categories
  • SEO
    • SEO Introduction
    • SEO Tactics and Methods
    • SEO Relevant Filenames
    • SEO Domain Name
    • Website Design and SEO
    • SEO Keywords
    • Meta Tags Optimization
    • Title Tag Optimization
    • Anchor Text Optimization
    • Content Optimization
  • Android
    • Android Introduction
    • Android History and Versions
    • Android Architecture
    • Android Environment Setup
    • Android Application Components
    • Hello World Application
    • Android Activities
  • iOS
    • iOS Introduction
    • iOS Environment Setup
    • iOS Architecture

You Are Here

  • Home
  • Learn HTML
  • HTML Input Attributes

Topics

  • HTML Introduction
  • HTML Editors
  • Fundamentals of HTML
  • HTML Elements
  • HTML Attributes
  • HTML Headings
  • HTML Paragraphs
  • HTML Style Attribute
  • HTML Text Formatting
  • HTML Phrase Tags
  • HTML Comments
  • HTML with CSS
  • HTML Links
  • HTML Images
  • HTML Tables
  • HTML Lists
  • HTML Blocks
  • HTML Class Attribute
  • Id Attribute for HTML
  • HTML Iframes
  • HTML JavaScript
  • HTML File Paths
  • HTML Head
  • HTML Computer Code Elements
  • HTML Entities
  • HTML Charset
  • HTML URL Encode
  • HTML and XHTML
  • HTML Layouts
  • HTML Forms
  • HTML Form Elements
  • HTML Form Input Types
  • HTML Input Attributes
  • HTML5 Introduction
  • HTML5 New Elements
  • Semantic Elements in HTML5
  • HTML5 Migration
  • Style Guide
  • HTML Canvas
  • HTML SVG

Oct Champs & Prizes

  • 1. Pooja Ladda
  • 2. Manjali Kuldharan
  • 3. Pranali Surawar
  • 4. Anjali Kulkarni
  • 5. Vishal Deshmukh

Recent Posts

  • HTML Media
  • jQuery Siblings
  • Bootstrap 4 Cards
  • jQuery Descendants
  • jQuery Ancestors

HTML Input Attributes

The HTML value Attribute:

The value attribute is one of the HTML input attributes and used to define the initial value of the input element.

Example:

<form>
Name:
<input type="text" name="firstname" value="David">
</form>
Try it

The HTML readonly Attribute:

The read-only attribute is one of the HTML input attributes and used to define that the text written in the input or text area is read-only. It means the user cannot modify the content already present in the input field.

Example:

<form>
First name:
<input type="text" name="firstname" value ="David" readonly><br><br>
Last name:
<input type="text" name="lastname">
</form>
Try it

The HTML disabled Attribute:

The disabled attribute is one of the HTML input attributes and used to define that the input field is disabled. The input field which is disabled is un-clickable and unusable. The values of the disabled input field will not be sent while submitting the form.

Example:

<form>
First name:
<input type="text" name="firstname" value ="David" disabled><br><br>
Last name:
<input type="text" name="lastname">
</form>
Try it

The HTML size Attribute:

The HTML size attribute is used to specify the size of the input field in terms of characters.
It works with many input fields like text, search, email, password, etc.

Example:

<form>
First name:
<input type="text" name="firstname" value="David" size="30"><br><br>
Last name:
<input type="text" name="lastname">
</form>
Try it

The HTML maxlength Attribute:

The maxlength attribute is used to define the maximum number of characters allowed in the input field. If you use maxlength attribute, the input field will not accept more than the allowed number of characters.

Example:

<form>
First name:
<input type="text" name="firstname" maxlength="20"> <br><br>
Last name:
<input type="text" name="lastname">
</form>
Try it

HTML5 Attributes

HTML5 added the some new attributes for <input>:

The autocomplete Attribute:

The HTML autocomplete attribute is used to specify whether the input field should have autocomplete on or off. When autocomplete attribute is set to on, the browser will automatically complete the input values based on values that the user has entered before. It works with input fields like text, search, URL, email, password, date pickers, range, and color.

Example:

<form action="/sample_page.php" autocomplete="on">
First name: <input type="text" name="fname"><br><br>
Last name: <input type="text" name="lname"><br><br>
E-mail: <input type="email" name="email" autocomplete="off"><br><br>
<input type="submit">
</form>
Try it

The novalidate Attribute:

The novalidate attribute is used to specify that the data of the form should not be validated when submitting the form. It is used with the HTML <form> element.

Example:

<form action="/sample_page.php" novalidate>
E-mail: <input type="email" name="user-mail">
<input type="submit">
</form>
Try it

The autofocus Attribute:

The autofocus attribute is used to specify that the input field should get focus when the page loads.

Example:

<form action="/sample_page.php">
First name: <input type="text" name="fname" autofocus><br><br>
Last name: <input type="text" name="lname"><br><br>
<input type="submit">
</form>
Try it

The form Attribute:

The form attribute is used to specify that the element can contain one or more forms.

Example:

<form action="/sample_page.php" id="form">
First name: <input type="text" name="fname"><br>
<input type="submit" value="Submit">
</form>
Last name: <input type="text" name="lname" form="form">
Try it

The formaction Attribute:

The formaction attribute is used to specify the URL of a file that will process the input control when the form is submitted. It overrides the action attribute of an <form> element and it is used with type=”submit” and type=”image”.

Example:

<form action="/sample_page.php">
First name: <input type="text" name="fname"><br><br>
Last name: <input type="text" name="lname"><br><br>
<input type="submit" value="Submit"><br><br>
<input type="submit" formaction="/sample_page2.php" value="Submit the form to another page">
</form>
Try it

The formenctype Attribute:

The formenctype attribute is used to specify that the data of the form should be encoded when submitting to the server. The formenctype attribute is used only for the forms with the method=”post”. It overrides the enctype attribute of the <form> element. It is used with type=”submit” and type=”image”.

Example:

<form action="/sample_page_binary.asp" method="post">
First name: <input type="text" name="fname"><br><br>
<input type="submit" value="Submit">
<input type="submit" formenctype="multipart/form-data" value="Submit as Multipart/form-data">
</form>
Try it

The formmethod Attribute:

The formmethod attribute specifies the HTTP method (GET or POST) to be used when the form data is submitted to the server. It overrides the method attribute of the <form> element. This attribute is used with type=”submit” and type=”image”.

Example:

<form action="/sample_page.php" method="get">
First name: <input type="text" name="fname"><br><br>
Last name: <input type="text" name="lname"><br><br>
<input type="submit" value="Submit">
<input type="submit" formmethod="post" value="Submit using POST">
</form>
Try it

The formnovalidate Attribute:

The formnovalidate attribute is used to specify that the input field should not be validated while submitting the form. It overrides the novalidate attribute of the <form> element and it is used with the type=”submit”.

Example:

<form action="/sample_page.php">
E-mail: <input type="email" name="email"><br><br>
<input type="submit" value="Submit"><br><br>
<input type="submit" formnovalidate value="Submit without validation">
</form>
Try it

The formtarget Attribute:

The formtarget HTML attribute is used to specify where to display the response that is received after submitting the form.
It overrides the target attribute of the <form> element and it is used with type=”submit” and type=”image”.

Example:

<form action="/sample_page.php">
First name: <input type="text" name="fname"><br><br>
Last name: <input type="text" name="lname"><br><br>
<input type="submit" value="Submit as normal">
<input type="submit" formtarget="_blank" value="Submit to a new window/tab">
</form>
Try it

The height and width Attributes:

The height and width attributes are used to specify the height and width of an <input type=”image”> element.

Example:

<form action="/sample_page.php">
First name: <input type="text" name="fname">
Last name: <input type="text" name="lname"><br>
<input type="image" src="submit.png" alt="Submit" width="50" height="50">
</form>
Try it

The list Attribute:

The list attribute is used to identify a list of pre-defined options for an <input> element.

Example:

<form action="/sample_page.php" method="get">
<input list="technologies" name="technology">
<datalist id="technologies">
<option value="HTML">
<option value="CSS">
<option value="JavaScript">
<option value="jQuery">
<option value="Bootstrap">
</datalist>
<input type="submit">
</form>
Try it

The min and max Attributes:

The min and max attributes are used to define the minimum and maximum values for an <input> element. It works with the number, range, date, datetime-local, month, time and week input types.

Example:

<form>
Enter a date before 1970-01-01:
<input type="date" name="bday" max="1969-12-31"><br><br>
Enter a date after 2002-01-01:
<input type="date" name="bday" min="2002-01-02"><br><br>
<input type="submit">
</form>
Try it

The multiple Attribute:

The multiple attribute is used to define that the user is allowed to enter more than one value in the <input> element.

Example:

<form action="/sample_page.php">
Select files: <input type="file" name="file" multiple><br>
<input type="submit">
</form>
Try it

The pattern Attribute:

The pattern attribute is used to specify the regular expression on which the input element value is checked. It works with the following input types: text, password, search, date, url, email, tel, etc.

Example:

<form action="/sample_page.php">
Password: <input type="text" name="Password" pattern="[A-Za-z]{6}" title="6 letter Password">
<input type="submit">
</form>
Try it

The placeholder Attribute:

The placeholder attribute is used to specify a short hint that describes the expected value of an input field. It is displayed in the input field before the user enters a value. It works with the following input types: text, search, tel, url, password and email.

Example:

<form action="/sample_page.php">
<input type="text" name="fname" placeholder="Enter your First Name"><br><br>
<input type="text" name="lname" placeholder="Enter your Last name"><br><br>
<input type="submit" value="Submit">
</form>
Try it

The required Attribute:

The required attribute is used to specify that the input field must be filled out before submitting the form. It works with the following input types: text, number, radio, checkbox, password, etc.

Example:

<form action="/sample_page.php">
Username: <input type="text" name="usrname" required><br><br>
Password: <input type="password" name="password" required><br>
<input type="submit">
</form>
Try it

The step Attribute:

The step attribute is used to set the legal number of intervals for an <input> element. Steps are the number of steps like 0, 2,4, 6,8, etc. It is used with the max and min attributes to create a legal range of legal values.

Example:

<form action = "/sample_page.php">
<input type = "number" name = "points" step = "4">
<input type = "submit" value = "Submit">
</form>
Try it

Post navigation

HTML Form Input Types
HTML5 Introduction

Ask a Question Cancel reply

Your email address will not be published. Required fields are marked *

W3 CODING SCHOOLS © Copyright 2019-20
Privacy policy   Terms of use

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok