Home > Article > Web Front-end > How to set the width of td with css
In CSS, you can use the width attribute to set the td width. You only need to set the "width:width value;" style to the td element. The width attribute sets the width of an element, which defines the width of the element's content area, excluding padding, borders, or margins.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
Define a tableb table
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <table border="1"> <tr> <th>商品</th> <th>价格</th> </tr> <tr> <td>T恤</td> <td>¥100</td> </tr> <tr> <td>牛仔褂</td> <td>¥250</td> </tr> <tr> <td>牛仔库</td> <td>¥150</td> </tr> </table><br /> </body> </html>
##How to set the width of td using css?
You can use the width attribute to set the td width, syntax:td{ width:100px; }Rendering: (Learning video sharing:
css video tutorial)
Instructions: The
width attribute sets the width of the element. Note: The width attribute does not include padding, borders and margins! Attribute value:Description | |
---|---|
default value. The browser can calculate the actual width. | |
length | Use px, cm and other units to define the width.|
% | Defines the width as a percentage based on the width of the containing block (parent element).|
Specifies that the value of the width attribute should be inherited from the parent element. |
Introduction to Programming! !
The above is the detailed content of How to set the width of td with css. For more information, please follow other related articles on the PHP Chinese website!