InterviewSolution
Saved Bookmarks
| 1. |
Explain the new input types provided by HTML5. |
|
Answer» There are many new INPUT types introduced in HTML5. These are in addition to the one we have seen in Question 25. So, the new types are -
We will use all the above to create our example. <!DOCTYPE html> <html> <head> <meta CHARSET="utf-8" /> <title>Input types</title> <style> h1{ text-align: center; } form{ display: grid; place-content: center; grid-gap: 10px; border: 1px solid black; } form > * { display: grid; grid-template-columns: 150px 1fr; place-content: center; } label { font-family: "Fira Sans", sans-serif; } </style> </head> <body> <h1>HTML5 Input Types Demo</h1> <form> <div id="search_eg"> <label for="site-search">Search the site:</label> <input type="search" id="site-search" name="q" aria-label="Search through site content"> </div> <div id="time_eg"> <label for="appt">Choose a time:</label> <input type="time" id="appt" name="appt" min="9:00" max="18:00" required> </div> <div id="url_eg"> <label for="url">Enter an URL:</label> <input type="url" name="url" id="url" placeholder="https://example.com" pattern="https://.*" size="30" required> </div> <div id="phone_eg"> <label for="phone">Enter your phone:</label> <input type="tel" id="phone" name="phone" placeholder="123-456-7890" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}" required> </div> <div id="month_eg"> <label for="month">Enter a month:</label> <input type="month" id="month" name="month" min="2018-03" value="2019-05"> </div> <div id="email_eg"> <label for="email">Enter your email:</label> <input type="email" id="email" pattern=".+@gmail.com" size="30" required> </div> <div id="number_eg"> <label for="tentacles">Enter a number:</label> <input type="number" id="tentacles" name="tentacles" min="10" max="100"> </div> <div id="range_eg"> <label for="volume">Choose a Range:</label> <input type="range" id="START" name="volume" min="0" max="11"> </div> <div id="color_eg"> <label for="favorite">Choose a color:</label> <input type="color" id="favorite" name="favorite" value="#e66465"> </div> <div id="date_eg"> <label for="date">Select a date:</label> <input type="date" id="date" name="date-start" value="2019-04-22" min="2018-01-01" max="2025-12-31"> </div> <div id="datetime_eg"> <label for="appointment-time">Choose a time:</label> <input type="datetime-local" id="appointment-time" name="appointment-time" value="2019-04-12T19:30" min="2019-04-07T00:00" max="2025-06-14T00:00"> </div> </form> </body> </html> |
|