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
Table of contents Preface Function Overloading Ma...
When doing DB benchmark testing, qps and tps are ...
Table of contents 1. System environment 2. Operat...
What Beautiful HTML Code Looks Like How to write ...
Table of contents 1. What content usually needs t...
What to do if you forget Windows Server 2008R2 So...
This article mainly introduces the sql serial num...
This article describes the commonly used MySQL fu...
for loop The for loop loops through the elements ...
This article shares the implementation code of jQ...
Copy code The code is as follows: html, address, ...
Benefits of a programmatic approach 1. Global con...
When executing yum in dockerfile or in the contai...
In order to extend the disk life for storing audi...
Table of contents 1. Why use slots? 1.1 slot 1.2 ...