Click here to return to the 123WORDPRESS.COM HTML Tutorial section. Previous: Markup Language - Quote <br />Original source chapter 5 Form interactivity has always been the focus of the Internet, allowing users and websites to exchange information and communicate with each other. Forms allow us to collect information from users in an organized and consistent manner, so when designing a website, they always fall into the "can be used in any situation" category. For example, we found that there are about 10,000 different ways to mark up forms. Okay, maybe not that many, but we can still think of several situations that make the form structure easy for users to use and easy for website owners to manage. Methods for marking forms Method A: Use a table
Many people have long used tables to mark up forms. Due to the high frequency of use, we are used to seeing forms laid out in this way: the left column is right-aligned text descriptions, and the right column is left-aligned form elements. Using a simple two-column table is one of the simple ways to complete easy-to-use form layout. Some people think that tables are unnecessary, while others think that forms should be treated as tabular data. We don't intend to support either view, but in some cases, using a table is the best way to achieve a certain form layout, especially complex forms with many different elements (forms using radio buttons, drop-down boxes, etc.). Relying entirely on CSS to handle the layout of such forms can be frustrating, and often requires adding extra <span> and <div> tags, which consumes more markup than a table would. Next, look at Figure 5-1, which shows the effect of method A in a general visual browser display: ![]() Figure 5-1: The effect of method A displayed in the browser You will find that using a table can arrange the text description form elements very neatly. However, for such a simple form, I might avoid using a table and use other methods that do not require so many tags. Unless the visual design of the form requires this type of layout, it is not necessary to use a table. At the same time, we also have to consider several usability issues, which we will touch upon when studying the following two methods. Method B: No need for tables, just squeeze together<form action="/path/to/script" method="post"> <p> Name: <input type="text" name="name" /><br /> Email: <input type="text" name="email" /><br /> <input type="submit" value="submit" /> </p> </form> input{ margin:6px 0; } |
<form action="/path/to/script" id="thisform" method="post">
<p><label for="name">Name:</label><br />
<input type="text" id="name" name="name" /></p>
<p><label for="email">Email:</label><br />
<input type="text" id="email" name="email" /></p>
<p><input type="submit" value="submit" /></p>
</form>
#thisform p{
margin:6px 0;
}
<form action="/path/to/script" id="thisform" method="post">
<p><label for="name">Name:</label> <br />
<input type="text" id="name" name="name" /></p>
<p><label for="email">Email:</label><br />
<input type="text" id="email" name="email" /></p>
<p><input type="submit" value="submit" /></p>
</form>
<form action="/path/to/script" id="thisform" method="post">
<p><label for="name">Name:</label><br />
<input type="text" id="name" name="name" /></p>
<p><label for="email">Email:</label><br />
<input type="text" id="email" name="email" /></p>
<p><input type="checkbox" id="remember" name="remember" />
<label for="remember">Remember this info?</label></p>
<p><input type="submit" value="submit" /></p>
</form>
<<: Docker pull image and tag operation pull | tag
>>: vue front-end HbuliderEslint real-time verification automatic repair settings
Good HTML code is the foundation of a beautiful w...
1. Command method Run the nginx service in the cr...
<br />The most common mistake made by many w...
Pure js implements a single-click editable table ...
When learning about inline-block, I found that the...
Recently the company has arranged to do some CCFA...
First, download the installation package from the...
1. Introduction to Logrotate tool Logrotate is a ...
dl:Definition list Definition List dt:Definition t...
The <tbody> tag is used to define the style...
Table of contents Overview 1. Hook calling order ...
1.Tomcat Optimization Configuration (1) Change To...
We often need to summarize data without actually ...
I saw an article in Toutiao IT School that CSS pe...
First, let's simulate the data coming from th...