HTML tag easy to mix and error small summary

Source: Internet
Author: User
Tangled up the day, and finally the correct use of the HTML tags, the applicability of their respective clearly understood, here is a simple summary to avoid making similar mistakes.

It's all because of a problem like this


To run the above code, when nothing is entered when the "Login" button, will prompt "user name can not be empty", but only a moment will flash back. What is the reason?

The point is here.

At this point there will be two events triggered, first call the onclick corresponding function, and then automatic submit (because the type is a submit at this time), will naturally overwrite the hint. So the type is set to a button to resolve.

Here's a quick summary,

HtmlThe Type property of the label

value Description
button Define clickable buttons ( in most cases, use JavaScript to launch scripts ).
CheckBox Define the check box.
File Define input fields and "Browse" buttons for file uploads.
Hidden Defines the hidden input field.
Image Defines the submit button in the form of an image.
Password Defines the password field. The characters in the field are masked.
Radio Defines a radio button.
Reset Defines the reset button. The reset button clears all the data from the form.
Submit Define the Submit button. The submit button sends the form data to the server.
Text Defines an input field for a single line in which the user can enter text. The default width is 20 characters.
Note: Type=button: simply a button function; Type=submit: Send form .

HTML label Type property

value Description
Submit The button is a Submit button (except Internet Explorer, which is the default value for other browsers).
button the button is a clickable button (the default value for Internet Explorer).
Reset the button is the reset button (clears the form data).
not finished ...

Copyright notice: This article is a blogger original article, not allowed to be reproduced without the permission of Bo master.

Above describes the HTML tags easy to mix and error small summary, including aspects of the content, I hope to be interested in PHP tutorial friends helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.