In CSS, width means "width" and is an attribute used to set the width of an element. The basic syntax format is "width:length|%;"; this attribute can define the width of the element's content area. You can add padding, borders, and margins outside the content area.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
css width attribute
The width attribute sets the width of the element.
Note: The width attribute does not include padding, borders and margins!
The width attribute defines the width of the element's content area. Pads, borders, and margins can be added outside the content area. Inline non-replaced elements ignore this attribute.
Attribute value:
auto 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).
#inherit Specifies that the value of the width attribute should be inherited from the parent element.
【Recommended tutorial: CSS video tutorial】
Example:
<!DOCTYPE html> <html> <head> <style type="text/css"> img { width: 300px } </style> </head> <body> <img src="img/1.jpg" / alt="What does width mean in css" > </body> </html>
For more programming-related knowledge, please visit: Introduction to Programming! !
The above is the detailed content of What does width mean in css. For more information, please follow other related articles on the PHP Chinese website!