Front-end learning-Frequently seen width

Source: Internet
Author: User

0. Preface width is often used in HTML design. width can effectively control the width and height of webpage elements, but width has two completely different forms: attributes and styles. In HTML, attributes and webpage tags are enclosed in <>, while styles are accompanied by styles. The object meta in table has the width attribute, while most form controls do not have the width attribute. You can only set the width through the style. This method is often incorrect: <input type = "text" width = "100px"> The following describes the problem through several examples.
1. width in the table -- attributes and styles in the Attribute Table can change the width to indicate that the problematic table has an outer border. [Webpage effect]
Figure 1 set the cell width in the table [attribute method]

<! DOCTYPE html> [Style method]
<! DOCTYPE html> [Difference] [1] attribute Syntax: <tr> <td width = "100px"> 100px </td> </tr> [2] Table Syntax: <tr> <td style = "width: 200px"> 200px </td> </tr> [3] The effect is identical.

2. width in the form -- style although the cells in the table can control the width through the width attribute, the form does not have the width attribute (except the image control in the form), because there is no attribute, only the form width can be set through the style. <Input type = "text" width = "100px"> This method has no effect, because the text box does not have this attribute. [Webpage effect]
Figure 2 set the width of the form text control [style method]
<! DOCTYPE html> [Summary] [1] <input type = "text" value = "100px" style = "width: 100px"> set the width



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.