Let's Play Around With Different Attributes and Input Types in HTML 5

Introduction

 
Today, in this article let's dig out by learning another new concept in HTML 5. Once implemented, this concept offers a better look & feel for the application and development becomes more light-weight.
 
Let's get this started off!!!
 
Question: What is the Autofocus Attribute?
 
In simple terms "It provides displaying of the cursor when the page gets loaded. It enables the user to directly enter some values or perform some expected operation".
 
Step 1: The complete code of Autofocus.html looks like this
  1. <! DOCTYPE html>  
  2.  <html>  
  3.  <body>  
  4.      <div>  
  5.          <header>  
  6.  <h1 style="color: gray; text-align:center">Working with Autofocus in HTML 5</h1>  
  7.  </header>  
  8.          <div style="text-align: center">  
  9.              FirstName:  
  10.              <input type="text" name="fullname" autofocus="autofocus" />  
  11.              <footer>  
  12.  <p style="color: silver; text-align:center">© Copyright  by Vijay Prativadi</p>  
  13.  </footer>  
  14.          </div>  
  15.  </body>  
  16.  </html> 
Step 2: The output of the Autofocus Application looks like this:
 
html5.jpg
 
Question: What is Required Attribute?
 
In simple terms "It shows a validation to the user for some mandatory fields which haven't been entered or left blank".
 
Step 1: The complete code of the Required.html looks like this
  1. <! DOCTYPE html>  
  2.  <html>  
  3.  <head>  
  4.  </head>  
  5.  <body>  
  6.      <form>  
  7.      <div>  
  8.          <header>  
  9.  <h1 style="color: gray; text-align:center">Working with Required in HTML 5</h1>  
  10.  </header>  
  11.          <center>  
  12.              <table>  
  13.                  <tr>  
  14.                      <td>  
  15.                          LastName:  
  16.                      </td>  
  17.                      <td>  
  18.                          <input type="text" name="lastname" required="required" />  
  19.                          <input type="Submit">  
  20.                      </td>  
  21.                  </tr>  
  22.              </table>  
  23.          </center>  
  24.          <footer>  
  25.  <p style="text-align: center; color: silver">© Copyright  by Vijay Prativadi</p>  
  26.  </footer>  
  27.      </div>  
  28.      </form>  
  29.  </body>  
  30.  </html> 
Step 2: The output of the Required Application looks like this
 
image2.jpg
 
Question: What is Step Attribute?
 
In simple terms "It provides flexibility for the user to step up or step down to provide some value for the required field".
 
Step 1: The complete code of Step.html looks like this:
  1. <! DOCTYPE html>  
  2.  <html>  
  3.  <head>  
  4.  </head>  
  5.  <script type="text/javascript">  
  6.      function rangeData(somevalue) {  
  7.          ElementById("range").innerHTML = somevalue;  
  8.      }  
  9.  </script>  
  10.  <body>  
  11.      <div>  
  12.          <header>  
  13.  <h1 style="color: gray; text-align:center">Working with Step in HTML 5</h1>  
  14.  </header>  
  15.          <div>  
  16.              <center>  
  17.                  <table>  
  18.                      <tr>  
  19.                          <td>  
  20.                              Step Attribute:  
  21.                          </td>  
  22.                          <td>  
  23.                              <input type="range" max="100" min="0" step="10" value="go" onchange="rangeData(this.value)" />  
  24.                              <span id="range">0</span>  
  25.                          </td>  
  26.                      </tr>  
  27.                  </table>  
  28.              </center>  
  29.              <footer>  
  30.  <p style="text-align: center; color: silver">© Copyright  by Vijay Prativadi</p>  
  31.  </footer>  
  32.          </div>  
  33.  </body>  
  34.  </html> 
Step 2:  The output of Step Application looks like this:
 
image3.jpg
 
Question: What is Max & Min(Range) Attribute?
 
In simple terms "It enables the user to select a required value within specified range".
 
Step 1: The complete code of maxandmin.html looks like this:
  1. <! DOCTYPE html>  
  2.  <html>  
  3.  <body>  
  4.      <div>  
  5.          <header>  
  6.  <h1 style="color: gray; text-align:center">Working with Max and Min(Range) in HTML 5</h1>  
  7.  </header>  
  8.          <div>  
  9.              <center>  
  10.                  <table>  
  11.                      <tr>  
  12.                          <td>  
  13.                              Max and Min:  
  14.                          </td>  
  15.                          <td>  
  16.                              <input type="date" name="date1" max="2012-02-25" min="1986-01-26" />  
  17.                          </td>  
  18.                      </tr>  
  19.                  </table>  
  20.              </center>  
  21.              <footer>  
  22.  <p style="text-align: center; color: silver">© Copyright  by Vijay Prativadi</p>  
  23.  </footer>  
  24.          </div>  
  25.  </body>  
  26.  </html> 
Step 2:  The output of max and min Application looks like this
 
image4.jpg
 
Question: What is Color Type?
 
In simple terms "It provides flexibility for the user to choose a required color from the picker".
 
Step 1: The complete code of Color.html looks like this:
  1. <! DOCTYPE html>  
  2.  <html>  
  3.  <head>  
  4.  </head>  
  5.  <body>  
  6.      <form>  
  7.      <div>  
  8.          <header>  
  9.  <h1 style="color: gray; text-align:center">Working with Color Picker in HTML 5</h1>  
  10.  </header>  
  11.          <center>  
  12.              <table>  
  13.                  <tr>  
  14.                      <td>  
  15.                          Pick The Color:  
  16.                      </td>  
  17.                      <td>  
  18.                          <input type="color" name="democolor" />  
  19.                      </td>  
  20.                  </tr>  
  21.              </table>  
  22.          </center>  
  23.          <footer>  
  24.  <p style="text-align: center; color: silver">© Copyright  by Vijay Prativadi</p>  
  25.  </footer>  
  26.      </div>  
  27.      </form>  
  28.  </body>  
  29.  </html> 
Step 2: The output of the Color Application looks like this:
 
image5.jpg
 
Question: What is Search Type?
 
In simple terms "It enables the user to search some specific matched terms on website".
 
Step 1: The complete code of Search.html looks like this:
  1. <! DOCTYPE html>  
  2.  <html>  
  3.  <head>  
  4.  </head>  
  5.  <body>  
  6.      <form>  
  7.      <div>  
  8.          <header>  
  9.  <h1 style="color: gray; text-align:center">Working with Search Attribute in HTML 5</h1>  
  10.  </header>  
  11.          <center>  
  12.              <table>  
  13.                  <tr>  
  14.                      <td>  
  15.                          Search:  
  16.                      </td>  
  17.                      <td>  
  18.                          <input type="search" name="demosearch" />  
  19.                      </td>  
  20.                  </tr>  
  21.              </table>  
  22.          </center>  
  23.          <footer>  
  24.  <p style="text-align: center; color: silver">© Copyright  by Vijay Prativadi</p>  
  25.  </footer>  
  26.      </div>  
  27.      </form>  
  28.  </body>  
  29.  </html> 
Step 2: The output of the Search Application looks like this:
 
image6.jpg
Question: What is Email Type?
 
In simple terms "It enables the user to enter valid email type into the textbox".
 
Step 1: The complete code of Email.html looks like this:
  1. <! DOCTYPE html>  
  2.  <html>  
  3.  <head>  
  4.  </head>  
  5.  <body>  
  6.      <form>  
  7.      <div>  
  8.          <header>  
  9.  <h1 style="color: gray; text-align:center">Working with Email in HTML 5</h1>  
  10.  </header>  
  11.          <center>  
  12.              <table>  
  13.                  <tr>  
  14.                      <td>  
  15.                          Email:  
  16.                      </td>  
  17.                      <td>  
  18.                          <input type="email" name="email" required="required" />  
  19.                          <input type="Submit">  
  20.                      </td>  
  21.                  </tr>  
  22.              </table>  
  23.          </center>  
  24.          <footer>  
  25.  <p style="text-align: center; color: silver">© Copyright  by Vijay Prativadi</p>  
  26.  </footer>  
  27.      </div>  
  28.      </form>  
  29.  </body>  
  30.  </html> 
Step 2: The output of Email Application looks like this:
 
imahe7.jpg
Question: What is Date Time Type?
 
In simple terms "It enables the user to select specific date and time from chooser".
 
Step 1: The complete code of Date.html looks like this:
  1. <! DOCTYPE html>  
  2.  <html>  
  3.  <head>  
  4.  </head>  
  5.  <body>  
  6.      <form>  
  7.      <div>  
  8.          <header>  
  9.  <h1 style="color: gray; text-align:center">Working with Date Time Chooser in HTML 5</h1>  
  10.  </header>  
  11.          <center>  
  12.              <table>  
  13.                  <tr>  
  14.                      <td>  
  15.                          Choose Date & Time  
  16.                      </td>  
  17.                      <td>  
  18.                          <input type="datetime" name="demodatetime" />  
  19.                      </td>  
  20.                  </tr>  
  21.              </table>  
  22.          </center>  
  23.          <footer>  
  24.  <p style="text-align: center; color: silver">© Copyright  by Vijay Prativadi</p>  
  25.  </footer>  
  26.      </div>  
  27.      </form>  
  28.  </body>  
  29.  </html>
Step 2: The output of Date Application looks like this:
 
image8.jpg
Question: What is URL Type?
 
In simple terms "It enables the user to enter valid URL address".
 
Step 1: The complete code of URL.html looks like this:
  1. <! DOCTYPE html>  
  2.  <html>  
  3.  <head>  
  4.  </head>  
  5.  <body>  
  6.      <form>  
  7.      <div>  
  8.          <header>  
  9.  <h1 style="color: gray; text-align:center">Working with URL Type in HTML 5</h1>  
  10.  </header>  
  11.          <center>  
  12.              <table>  
  13.                  <tr>  
  14.                      <td>  
  15.                          Please Enter URL:  
  16.                      </td>  
  17.                      <td>  
  18.                          <input type="url" name="demourl" required="required" />  
  19.                          <input type="submit" />  
  20.                      </td>  
  21.                  </tr>  
  22.              </table>  
  23.          </center>  
  24.          <footer>  
  25.  <p style="text-align: center; color: silver">© Copyright  by Vijay Prativadi</p>  
  26.  </footer>  
  27.      </div>  
  28.      </form>  
  29.  </body>  
  30.  </html>
Step 2: The output of the URL Application looks like this
 
image9.jpg
 


MVC Corporation
MVC Corporation is consulting and IT services based company.