04.06.2013 Views

Head First HTML with CSS

Head First HTML with CSS

Head First HTML with CSS

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.

adding input elements<br />

Back to getting those elements into your X<strong>HTML</strong><br />

Now we’ve got to get those elements inside the form.<br />

Check out the additions below, and then make the changes in<br />

your “form.html”. Here’s JUST the form<br />

We’re going to<br />

start by putting<br />

everything inside<br />

a element.<br />

<br />

608 Chapter 14<br />

Ship to: <br />

Name: <br />

Address: <br />

City: <br />

State: <br />

Zip: <br />

<br />

<br />

<br />

<br />

We’ve added a label for each<br />

input so the user knows what<br />

goes in the text input.<br />

You can only nest block elements<br />

directly inside a form.<br />

<br />

And you should also know that is an<br />

inline element, so if you want some linebreaks<br />

between the elements, you have to<br />

add s. That’s also why you need to<br />

nest them all inside a paragraph.<br />

Finally, don’t forget that users need a submit button to<br />

submit the form. So add a submit button by inserting an<br />

at the bottom <strong>with</strong> a type of “submit”. Also add<br />

a value of “Order Now”, which will change the text of the<br />

button from “Submit” to “Order Now”.<br />

snippet from “form.html”.<br />

Hey, we’ve got to save a<br />

few trees here!<br />

After you’ve made all these changes, save your “form.html” file<br />

and let’s give this a whirl. Don’t forget to validate your<br />

X<strong>HTML</strong>. Forms elements need<br />

validation too!<br />

Here are all<br />

the <br />

elements: one<br />

for each text<br />

input in the<br />

“Ship to” section<br />

of the form.

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

Saved successfully!

Ooh no, something went wrong!