CSS max-width property26 Mar 2025 | 3 min read Sometimes it is useful to limit the element's width to a certain range. There are two properties max-width and min-width used to set the maximum and minimum width of the element. The max-width property in CSS is used to set the maximum width of the element's content box. It means that the width of the content box can be smaller than the max-width value, but cannot be greater. It sets the upper bound on the element's width. When the content is larger than the maximum width, then it will automatically change the height of the element. If the content is smaller than the max-width, this property has no effect. This property ensures that the value of width property cannot be greater than the value of max-width property. It does not allow negative values. SyntaxThe values of this CSS property are defined as follows. none: It is the default value that does not limit the width of the content box. length: This value defines the length of max-width in px, cm, pt, etc. initial: It sets the property to its default value. inherit: It inherits the property from its parent element. Now, let's see an example of this CSS property. ExampleIn this example, there are four paragraph elements with the content. We are defining the maximum-width of these paragraphs using the length value of max-width property. The maximum width of the first paragraph is 175px, the second paragraph is 20em, the third paragraph is 350pt, and the fourth paragraph is 10cm. The content of the first paragraph is larger than the value of max-width property, so in the output, we can see that the height of the first paragraph changed automatically. Output ![]() Next TopicCSS min-height |
property This CSS property specifies the duration to start the transition effect. The value of this property is defined as either seconds (s) or milliseconds (ms). The CSS transitions are effects that are added to change the element gradually from one style to another, without...
3 min read
The foundation of web design is Cascading Style Sheets (CSS), which gives developers control over the organisation and appearance of online pages. The placement of items on a webpage is one of the numerous functionalities it provides. Both "absolute" and "relative" positioning techniques are important in...
3 min read
Clearfix CSS What is CSS Clearfix? A CSS technique called clearfix keeps floated elements inside containers and ents them from collapsing when they contain floated child elements. Elements that are floated in CSS are removed from the standard document flow, which occasionally causes problems with their parent...
5 min read
CSS Text Stroke Introduction to CSS CSS is a style sheet language, also known as Cascading Style Sheets, used in web development to manage the appearance and organization of HTML documents. It also helps us specify details like color schemes, fonts, margins, padding, and the positioning of...
4 min read
This CSS property specifies the order of the flex item in the grid container or flex. It is basically used for ordering the flex items. It is to note that, if the element isn't flexible, then this property will not work. The elements will get displayed...
4 min read
What is the Latest Version of CSS? As we all know, CSS is an essential tool in web development that is used to style the HTML element, and we can also format how elements will appear on a webpage. With the help of new or the latest...
6 min read
This CSS property specifies the left offset for the horizontal positioned elements and does not affect the non-positioned elements. It is one of the four offset properties that are right, top, and bottom. When both left and right properties are defined, the right value has a...
3 min read
CSS outline is just like CSS border property. It facilitates you to draw an extra border around an element to get visual attention. It is as easy as to apply as a border. See this example: <!DOCTYPE html> <html> <style type="text/css"> .box { background-color:...
3 min read
CSS Superscript and Subscript In HTML, there is the use of <sub> and <sup> tags to define the subscript and superscript text. The superscript text appears in a smaller font and the half character above the normal line. It is generally used to write mathematical equations...
2 min read
In web design, buttons are of great importance. Buttons are clickable elements that are used to interact with users so that users can easily navigate a website. It gives an attractive look to the web page and enhances the user experience of the website. Although you...
28 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India