Label and span labels setting width is not a valid solution

Source: Internet
Author: User
how to use CSS to make label labels equal width. <div><label> password </label><input type= "password"/></div>
<div><label> Confirm password </label><input type= "password"/></div>
How to align it. The method of adding space is not good oh. (because the number of words in the label is not the same, so the page display effect is not aligned) the cause of the problem and the solution:

The label defaults to an inline element with no line breaks before and after the element, and no width can be set.

If you want to set the width for the label, you need to change the display property of the label to a block-level element.

The method is as follows:

1. Add Inline-block property value, change label label into inline block element (css2.1 Add)

{Display:inline-block;}
2. Increase the Width property, such as setting the breadth to 100px
Label{width:100px;display:inline-block;}
3. All label labels on the page will become 100px when added

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.