23.05.2015 Views

Building the User Interface by Using HTML5: Organization ... - server

Building the User Interface by Using HTML5: Organization ... - server

Building the User Interface by Using HTML5: Organization ... - server

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Building</strong> <strong>the</strong> <strong>User</strong> <strong>Interface</strong> <strong>by</strong> <strong>Using</strong> <strong>HTML5</strong>: <strong>Organization</strong>, Input, and Validation | 79<br />

The datalist element enables you to present <strong>the</strong> user with a drop-down list of options<br />

to select from. Only <strong>the</strong> options in <strong>the</strong> list may be selected. Alternately, you could insert<br />

type="text" into <strong>the</strong> input element to create a text box in which <strong>the</strong> user enters text. The<br />

following example lets <strong>the</strong> user select from one of three countries:<br />

<br />

<br />

<br />

<br />

<br />

<br />

LICENSED PRODUCT NOT FOR RESALE<br />

The search value for <strong>the</strong> type attribute enables you to create a search feature for a Web<br />

page. An example of <strong>the</strong> markup is:<br />

<br />

<br />

<br />

<br />

Finally, <strong>the</strong> autofocus attribute moves <strong>the</strong> focus to a particular input field when a Web<br />

page loads. An example of autofocus is when you open a search engine Web page and <strong>the</strong><br />

insertion point automatically appears in <strong>the</strong> input box so you can type search terms without<br />

first clicking in <strong>the</strong> box. An example of <strong>the</strong> markup to place <strong>the</strong> focus on a field named<br />

fname when a page loads is:<br />

<br />

autofocus has historically been handled <strong>by</strong> JavaScript, and if a user turns off JavaScript in a Web<br />

browser, <strong>the</strong> autofocus feature doesn’t work. To work around this issue, <strong>the</strong> <strong>HTML5</strong> autofocus<br />

attribute is supported <strong>by</strong> all major browsers and behaves consistently across all Web sites.<br />

CREATE A SIMPLE WEB FORM<br />

GET READY. To create a simple Web form, perform <strong>the</strong> following steps:<br />

1. <strong>Using</strong> an HTML editor or app development tool and a Web browser, create a simple<br />

Web form with <strong>the</strong> following markup:<br />

<br />

<br />

<br />

<br />

Contact Us<br />

<br />

<br />

<br />

<br />

<br />

Name<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!