{"id":14134,"date":"2011-09-06T19:00:03","date_gmt":"2011-09-07T02:00:03","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=14134"},"modified":"2021-03-03T09:20:29","modified_gmt":"2021-03-03T17:20:29","slug":"width","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/w\/width\/","title":{"rendered":"width"},"content":{"rendered":"\n

The width<\/code> property in CSS specifies the width of the element’s content area. This “content” area is the portion inside the padding<\/a>, border<\/a>, and margin<\/a> of an element (the box model<\/a>).<\/p>\n\n\n\n

.wrap { \n  width: 80%;\n}<\/code><\/pre>\n\n\n\n

In the example above, elements that have a class name of .wrap<\/code> will be 80% as wide as their parent element. The accepted values are any of the length values<\/a>, in addition to some keywords we’ll cover later.<\/p>\n\n\n\n

Width can be overridden by the closely correleated properties min-width<\/code><\/a> and max-width<\/code><\/a>.<\/p>\n\n\n\n

.wrapper-1 {\n  width: 100%;\n  max-width: 320px; \/* Will be AT MOST 320px wide *\/\n}\n\n.wrapper-2 {\n  width: 100%;\n  min-width: 20em; \/* Will be AT LEAST 20em wide *\/\n}<\/code><\/pre>\n\n\n\n