Problem solving a large blank space before and after a form element

Source: Internet
Author: User
Tags define object
Solve | The problem

Why is there a large blank space around the form element?

Solution Idea:

Because the table cell form is the default outer filler margin property is not 0 block elements, so there are two ways to solve the problem, define the block element as inline element, or set the CSS object's margin property to 0.

Specific steps:

Method One: Set the margin property of the CSS object to 0:

<div style= "border:1px solid #000" > First line <form style= "margin:0px" ></form> second line </div>

Method Two: Set the block element to the inline element:

<div style= "border:1px solid #000" > First line <form style= "Display:inline" ></form> first line </div>

Although there is also a <form> tag with <tr> or <td> nested writing, but not recommended:

<table><form><tr><td> Cell </td></tr></form></table>

Or

<table><tr><form><td> Cell </td></form></tr></table>

Note: The first method does not have the same text before and after the form, and the second method walks.

Tip: If you want to change the effect of all forms, you can define them directly in CSS:

<style>
form{margin:0px}
</style>

Or

<style>
Form{display:inline}
</style>

Special Tips

This example adds a DIV element and sets a border to allow the reader to see the effect more clearly. Figure 1.4.9, figure 1.4.10 and figure 1.4.11 are respectively set before and after the comparison of the effects of this example.

Figure 1.4.9 A form before it is set

Figure 1.4.10 A form set by method

Figure 1.4.11 A form set by method two

Special Notes

The solution of the problem is to make use of the characteristics of block element and inline element, to transform each other, and the margin attribute of CSS object. This example is primarily about solving form-related problems, and for more detailed display and margin properties of CSS objects, refer to the second section.

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.