The month type is used to specify the particular month and year by the user. The month type is used in <input> tag. It only specifies the month and year and not the date. To specify the complete date we can use date input type. One example is the credit card expiry date where only month and year is displayed.
Syntax month Input Type
<input type= “month”>
month type is supported by Chrome, Safari and Opera.
HTML5 date Input Type Example
<!DOCTYPE html> <head> <title>Month Input Type</title> </head> <body> <form> Your card expires on:<input type="month"> </form> </body> </html>
- In this program we have shown how to take month and year in the form.
- In this program we are setting month and year using the month type in input tag.
Example Application Test
- Save the file as month_example.html in your system.
- Just open the file in the browser, you will see the below picture in the browser. Note that the browser must support HTML5 specification.
When the execution process is completed successfully we will get the following output:
Something like this: