HTML Essential Training (2012)
Illustration by Richard Downs

Submit and button elements


HTML Essential Training (2012)

with Bill Weinman

Video: Submit and button elements

Form buttons are used to initiate an action. Let's make a working copy of buttons.html here from your Chap16 folder in the exercise files. I am going to rename that to buttons-working. I am going to open that in the text editor, and I am also going to go ahead and open that in the browser here. I am going to use Firefox for this. This works exactly the same in any browser. You notice here, in our HTML, we're loading the same forms.css and forms.js we've been using throughout this chapter.
Expand all | Collapse all
  1. 5m 24s
    1. Welcome
    2. Using the exercise files
      1m 37s
    3. What you need to know about this course
      2m 51s
  2. 22m 0s
    1. What is HTML?
      4m 12s
    2. Examining the structure of an HTML document
      7m 50s
    3. Understanding tags and containers
      6m 4s
    4. Exploring content models in HTML5
      2m 23s
    5. Looking at obsolete elements
      1m 31s
  3. 27m 19s
    1. Understanding whitespace and comments
      3m 53s
    2. Displaying text with paragraphs
      3m 37s
    3. Applying style
      8m 5s
    4. Using block and inline tags
      6m 34s
    5. Displaying characters with references
      5m 10s
  4. 16m 36s
    1. Exploring the front matter of HTML
      2m 9s
    2. Applying CSS to your document
      3m 59s
    3. Adding scripting elements
      4m 54s
    4. Using the meta tag
      3m 34s
    5. Optimizing your page for search engines
      2m 0s
  5. 24m 59s
    1. Controlling line breaks and spaces
      2m 46s
    2. Exploring phrase elements
      1m 44s
    3. Using font markup elements
      1m 5s
    4. Highlighting text with mark
      1m 29s
    5. Adding headings
      1m 38s
    6. Using quotations and quote marks
      3m 2s
    7. Exploring preformatted text
      1m 45s
    8. Formatting lists
      2m 28s
    9. Forcing text direction
      3m 49s
    10. Suggesting word-break opportunities
      2m 29s
    11. Annotating East Asian languages
      2m 44s
  6. 29m 15s
    1. Introducing CSS
    2. Understanding CSS placement
      6m 55s
    3. Exploring CSS syntax
      10m 34s
    4. Understanding CSS units of measure
      3m 3s
    5. Some CSS examples
      7m 48s
  7. 22m 5s
    1. Using images
      4m 13s
    2. Flowing text around an image
      4m 55s
    3. Breaking lines around an image
      3m 3s
    4. Aligning images
      5m 25s
    5. Mapping links in an image
      4m 29s
  8. 22m 28s
    1. Understanding URLs
      2m 41s
    2. Working with hyperlinks
      3m 28s
    3. Using relative URLs
      4m 20s
    4. Specifying a base URL
      2m 19s
    5. Linking within a page
      4m 12s
    6. Using image links
      5m 28s
  9. 17m 2s
    1. Exploring list types
      3m 52s
    2. List elements in depth
      7m 44s
    3. Using text menus with unordered lists
      5m 26s
  10. 15m 30s
    1. Introduction to HTML semantics
      4m 9s
    2. Exploring an example
      4m 56s
    3. Marking up figures and illustrations
      2m 33s
    4. Creating collapsible details
      3m 52s
  11. 11m 18s
    1. Embedding audio
      5m 19s
    2. Embedding video
      5m 59s
  12. 11m 53s
    1. Creating ad-hoc Document Object Model (DOM) data with the data-* attribute
      4m 53s
    2. Displaying relative values with meter
      2m 57s
    3. Creating dynamic progress indicators
      4m 3s
  13. 4m 49s
    1. Overview of HTML5 microdata
      1m 8s
    2. Exploring an example with microdata
      3m 41s
  14. 7m 3s
    1. Understanding outlines
    2. A demonstration of outlining
      6m 11s
  15. 13m 1s
    1. Table basics
      7m 29s
    2. Exploring the semantic parts of a table
      2m 32s
    3. Grouping columns
      3m 0s
  16. 9m 55s
    1. Frames overview
    2. Using traditional frames
      4m 26s
    3. Exploring inline frames using iframe
      2m 7s
    4. Simulating frames with CSS
      2m 28s
  17. 53m 7s
    1. Introducing forms
      10m 24s
    2. Using text elements
      10m 12s
    3. Using checkboxes and radio buttons
      2m 37s
    4. Creating selection lists and dropdown lists
      5m 14s
    5. Submit and button elements
      8m 48s
    6. Using an image as a submit button
      2m 15s
    7. Keeping context with the hidden element
      3m 0s
    8. Setting tab order
      2m 7s
    9. Preloading an autocomplete list using the datalist feature
      5m 26s
    10. Displaying results with output
      3m 4s
  18. 19m 47s
    1. Touring a complete site
      2m 14s
    2. Touring the HTML
      8m 44s
    3. Touring the CSS
      8m 49s
  19. 29s
    1. Goodbye

Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now
please wait ...
Watch the Online Video Course HTML Essential Training (2012)
5h 34m Beginner Sep 11, 2012 Updated Jan 05, 2015

Viewers: in countries Watching now:

This course introduces web designers to the nuts and bolts of HTML (HyperText Markup Language), the programming language used to create web pages. Author Bill Weinman explains what HTML is, how it's structured, and presents the major tags and features of the language. Discover how to format text and lists, add images and flow text around them, link to other pages and sites, embed audio and video, and create HTML forms. Additional tutorials cover the new elements in HTML5, the latest version of HTML, and prepare you to start working with Cascading Style Sheets (CSS).

Topics include:
  • What is HTML?
  • Using HTML tags and containers
  • Understanding block vs. inline tags
  • Controlling line breaks and spaces in text
  • Aligning images
  • Linking within a page
  • Using relative links
  • Working with tables
  • Creating progress indicators with HTML5
  • Adding buttons and check boxes to forms
  • Applying CSS
  • Optimizing your pages for search engines
  • Building document outlines
Developer Web
Bill Weinman

Submit and button elements

Form buttons are used to initiate an action. Let's make a working copy of buttons.html here from your Chap16 folder in the exercise files. I am going to rename that to buttons-working. I am going to open that in the text editor, and I am also going to go ahead and open that in the browser here. I am going to use Firefox for this. This works exactly the same in any browser. You notice here, in our HTML, we're loading the same forms.css and forms.js we've been using throughout this chapter.

And here's our form, and you will notice a couple of things about our form that are a little bit different. First of all, it has this action attribute, and the action attribute has the URL of a script on one of my servers. is one of my servers. That's my test server, and it's password-protected. You will not be able to use this resource in your working with the exercise files. So what I've done here I've included three different versions of this script-- one in PHP, one in Perl, and one in Python--and the Python one also has this little bwCGI library that it requires.

So I've included all of that in the exercise files, so you should be able to load this up on your own server. And just about every server available is going to support at least one of those languages; actually, it will mostly support all of those languages. Although some of them might be using an older version of Python, and this one uses Python 3, but it's really the same script in all of these different languages. If you don't have a server available, you can load one up on your desktop, and there's an excellent course on called Installing Apache, MySQL, and PHP that will show you how to install one of these packages like XAMPP or MAMP or one of those on your desktop.

I personally prefer the XAMPP one, X-A-M-P-P, but any of those will work for this purpose. So that allow you to test this, but actually, if you're watching this part of this course, you are probably implementing forms in some way, and you probably already have a server or some test environment for testing CGI, and you can use that with one of these scripts that I provided to follow along with this particular exercise. So in the action attribute is where you put the URL for whatever the script resource is; in this case, it's the cgi-test.php script on my server.

You will notice also that our onsubmit attribute has changed. We're now returning submitDisplay instead of just display. I just want to show you this in the script here so you can see. I am going to load up our forms.js and scroll down here to the bottom here. And you see submitDisplay, it actually calls display, but then it returns this flag, whether or not the validation happened. If we look at what happens here in our forms, both of these are flagged as being required. So if I press the Big Red Button, I get errors that say to Please fill out this field.

But if I fill them in, it will actually call the CGI script. It actually submits to my server. So, what this does, if the JavaScript returns false, it does not go ahead and submit the script to the action URL; and if it returns true, then it does. And so our JavaScript throughout the rest of the course is just always returning false because there isn't any external resource to be called. And in this case it's actually returning the actual results of the validation, so that it knows whether or not to submit it to the script.

So that's actually something that's good for you to know when you're writing your own JavaScripts so that you understand how to control whether or not it gets submitted to the external resource or not. One other thing that you'll notice here is that the method="post", and when method="post" all of these variables are submitted to the server in a way that is not immediately visible to you as the developer. They're sent as the body of the request behind the scenes. If we change this to method="get"--and those are the two choices here for method-- when it submits this resource--I am going to go ahead and I am going to reload this by putting my cursor up on the Location bar rather than just hitting the Reload button-- when you reload by putting your cursor on the Location bar and pressing the Enter key on your keyboard, it actually resets the form.

If I just reload by pressing this button, it will leave values here. I am going to go ahead and put the values back in, foo bar, and press the Big Red Button. And now you'll notice that all of those variables--text1, password1, submit1--are now passed on the URL, and so that's these text1, password1, submit1. Those are all now passed on the URL because we're in get mode. Sometimes that can be useful for testing; sometimes that's useful if you want to actually allow your users to bookmark a certain position or a certain result, like a search engine result.

You notice that search engines typically use the get mode. Other times it's just long and distracting, and you run the danger of somebody bookmarking something that you might not want them to. So you need to be aware of the distinction there. This is get mode, and this is post mode. Reload exercise again, and foo bar, press the Big Red Button, and this is post mode, where all of that does not show up on the URL bar. I am going to make this a little bit bigger here so we can see these values. Most of this stuff is things that you're not necessarily concerned about. These are useful for debugging something.

You notice we have environment variables. But here, these are the CGI values. This is the stuff that's the result of your form. You notice that my form has three elements and they have names: text1, password1, and submit1. And so these are getting sent to the script, and the script is returning the name and the value. Tthese are called name-value pairs. So this is a really useful script for debugging your CGI and how your forms interact with the server. So I recommend that you keep a copy of this. This is the PHP version, and I am just going to show you the other ones.

Here is the pl version, go ahead and reload, and submit again, and here's the pl version. You see that says in the URL bar and it says pl version here. You notice that this one is using Perl, and it does exactly the same thing, and the same with the Python version, show you that. And we'll go back and reload and enter data, and here's the Python version. You see it says py up there in the URL bar. and I am going to make this a little bigger for you.

And we can see, it has exactly the same results, only here it says Python version instead of Perl or PHP. So, all these scripts are available for you for your testing purposes. Now, I just want to show you a couple of other things about the buttons themselves. HTML also provides a Reset button, and I'm just doing this so that I can make a quick copy of this line. I'm going to call this one Reset and its value is going to be Reset Button, and it doesn't have any onclick, and I am going to name this reset1.

When I save this and reload it in the browser--come up here and do the full reload--you notice we now have a Big Red Button and a Reset Button. So if I type in some values here and I hit the Reset Button, it clears my form. And because these are both required values, it's also highlighting them in red. But this is a button for clearing the form, and this has been part of HTML since the very beginning of forms. And for the most part, the only purpose it serves is to annoy people. It resets the form to its original state, which is often unnecessary, and it just tends to annoy users who press it by accident.

There's usually other better ways to allow somebody to go back. In fact, usually if you have a multipage form, you have a Go Back button. And if you have a single page form, you don't really necessarily need a Reset Button. I am telling you about it because it's there and you're going to see it sometimes, you're going to want to know how it works, but for most part, I'm really not recommending that you use it. The one other type of button I want to show you is the one that's just called Button and it's not a Submit button. So I am just going to change the type of this to button and reload this page again.

And when I type in my form and press the button, you notice that even though I still have this submitDisplay and I haven't changed anything else here, it does not submit the form to the server in the background. This is a button that just acts as a button, and its only purpose is to call JavaScript. And so in this case, I am calling this submitDisplay, and so it's doing its job, but it's not doing anything else. It's not actually submitting the form to the server. So this is commonly used in JavaScrip- only applications, so it's something that you also need to know about.

Forms buttons are used to initiate action. Of course, you can also initiate action using DOM events, but the button user interface is intuitive and familiar, and should not be overlooked.

Find answers to the most frequently asked questions about HTML Essential Training (2012) .

Expand all | Collapse all
please wait ...
Q: The horizontal nab bar built in Chapter 8 doesn't work correctly in Internet Explorer 8. Do you have a solution?
A: Internet Explorer 8 does not support HTML5 and the NAV element.

The nab bar can work in IE 8 if you change the nav element to div, and update the CSS accordingly. You will also need to move the "display: inline" from the " li a" rule to the " li" rule.
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed HTML Essential Training (2012).

Return to your organization's learning portal to continue training, or close this page.


Course retiring soon

HTML Essential Training (2012) will be retired from the library on June 15, 2015. Training videos and exercise files will no longer be available, but the course will still appear in your course history and certificates of completion. For updated training, check out the all new HTML Essential Training in the Online Training Library.

Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.