HTML Form Rules

HTML Form Rules are the standard rules a website developer must consider when creating an HTML form,

Some of these rules are not compulsory because it doesn't affect any display of the content.

However, they are very necessary to practice.

Method Rules

This rule allows you to set the type of method you want your form to use in delivering data to the server.
We have two major types of values provided for the method attribute in a form element. They are:

  • GET Method
  • POST Method

GET Method

The "GET" value of the method attribute in an HTML form element is used to indicate that the form data should be delivered to the server through URL queries.
URL queries are information that is always part of the URL, they are usually preceded with a question mark (?) and each query is being separated with the ampersand (&). Example: https://lyty.dev/html/html-form-rule.html?webview=1&is_site=true

Example of a Get method

See Example

<form action="search_page.html" method="GET">
<!-- html input fields goes here -->
</form>

  Do It Yourself

The GET method normally displays users' input in the URL, it should not be used to collect sensitive data from the user.
This method will is set as default, if the method atrribute is not there.

You should not use a GET method for sensitive information input such as a login form that includes passwords and some other security information.
  Do It Yourself
a

POST Method

The "POST" value of the method attribute in an HTML form element is used to indicate that the form data should be delivered to the server without URL queries.
The user's data and information will not be visible in the URL.

Example of a Post method

See Example
<form action="landing_page.html" method="POST">
<!-- HTML input fields goes here ... -->
</form>

The "POST" value of the method attribute does not display users' input in the URL, it can be used to collect sensitive data from the user.

It is advisable to use a POST method for sensitive information inputs such as login form that includes passwords and some other security information.
  Do It Yourself

Structure of a basic Login page that covers Form Rules

What You Should Know at the End of This Lesson

  • You understand the Form Rules.
  • You should know when to used to post/get values of the <form> element method attribute.
  • You should be able to create a basic login form that covers the Form Rules.