- HTML Tutorial
- HTML - Home
- HTML - History and Evolution
- HTML - Overview
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Headings
- HTML - Paragraphs
- HTML - Quotations
- HTML - Comments
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Style Sheet
- HTML - CSS Classes
- HTML - CSS IDs
- HTML - Images
- HTML - Image Map
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Iframes
- HTML - Blocks
- HTML Backgrounds
- HTML - Backgrounds
- HTML Colors
- HTML - Colors
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Code Builder
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - step Attribute
The step attribute is an HTML attribute used to set the interval between legal numbers or the distinct step size of the <input> tag.
The step sets the stepping interval when clicking up and down spinner buttons, moving a slider left and right on a range, and validating the different data types. If not explicitly included, then the default value is set to 1 for number and range.
Note: The step attribute works with the following input types: number, range, date, datetime-local, month, time, and week. And this attribute can be used together with the max and min attributes to create a range of legal values.
The default stepping value for time is 1 second, with 900 begin equal to 15 minutes.
For example; if step = "3", legal number could be -3, 0, 3, 6, etc.
Syntax
Following is the syntax of the step attribute −
<input step = "value" >
Example
In the following example, we are using the step attribute in the input tag to increase or decrease the number by 5.
<!DOCTYPE html> <html> <head> <title>HTML step Attribute</title> <style> body { text-align: center; } </style> </head> <body> <h1 style="color: green;">tutorials <span style="color: black">point</span> </h1> <h2>HTML step Attribute</h2> <input type="number" name="tp" step="5" placeholder="multiples of 5"> </body> </html>
When we run the above code, it will generate an output consisting of the input field mentioned with step attribute displayed on the webpage.when the user tries to increases or decreases the value it give multiples of 5.
Example
Considering the another scenario, where we are going to use the step attribute by 2 on the input type=month.
<!DOCTYPE html> <html> <head> <title>HTML step Attribute</title> <style> body { text-align: center; } </style> </head> <body> <h1 style="color: green;">tutorials <span style="color: black">point</span> </h1> <h2>HTML step Attribute</h2> <input type="month" name="month" step="2" placeholder="month will step by 2"> </body> </html>
On running the above code, the output window will pop up displaying the input field applied with step attribute on the webpage.
Example
Let's look into the following example, where we are going to use the step attribute by 10 with the input type=range.
<!DOCTYPE html> <html> <head> <title>HTML step Attribute</title> <style> body { text-align: center; } </style> </head> <body> <h1 style="color: green;">tutorials <span style="color: black">point</span> </h1> <h2>HTML step Attribute</h2> <input type="range" name="range" step="10"> </body> </html>
When we run the above code, the output window will pop up displaying the range meter mentioned with step attribute displayed on the webpage.
To Continue Learning Please Login
Login with Google