CSS min-width Property

Learn via video course
FREE
View all courses
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
Topics Covered

Overview

The min-width property specifies the minimum width of an HTML element. The width's value cannot be smaller than the width's minimum value. The min-width property preserves the set minimum width even if the content supplied within the element is less and is ineffective if the content is larger than the minimum width.

NOTE : No matter where we place the min-width property in our declaration, it overrides the width property.

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Syntax for CSS min-width Property

The CSS min width property accepts keyword values such as auto, max-content, min-content, etc. It supports numeric values such as length in px, em, and percentage.

In the further sections of the article, we will discuss the values that the min-width property supports in more detail .

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data

Property Values of CSS min-width

ValueDescriptionSyntax
It defines the minimum width in px, cm, etc.min-width: example: min-width:100px;
It specifies the minimum width in percent of the containing blockmin-width: example : min-width:10%;
autoThe browser will calculate and select a min-width for the specified element with an auto value.min-width;
max-contentThe max-content value indicates the content's intrinsic maximum width. In the case of text-content, this means that even if the content overflows, it will not wrap.min-width;
min-contentA min-content sizing keyword specifies the content's intrinsic minimum width. The text content will take advantage of all soft-wrapping opportunities, resulting in the smallest possible size.min-width;
fit-contentThe fit-content value uses the fit-content formula with the available space replaced by the argument, i.e., min(max-content, max(min-content, argument)).min-width: fit-content(20em);

Examples of CSS min-width

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Setting Minimum Element w=Width

In this example, we'll set the minimum element width using the various values supported by the min-width property.

HTML:

CSS :

OUTPUT:

MIN WIDTH CSS

By using max-content, the text inside the fifth container is rendered as a single long line without breaking at any soft breakpoints.

MAX WIDTH USAGE

Browser Support

The following browsers support the CSS min width property:

BrowserVersion
Google Chrome1.0
Safari1.0
Mozilla Firefox1.0
Microsoft Edge12.0
Opera4
Chrome Android18
Firefox for Android4
Opera Android10.1
Safari on iOS1
Samsung Internet1.0
WebView Android4.4

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data

Conclusion

  • The min-width property in CSS defines the minimum width of an element.
  • The CSS min width property preserves the set minimum width even if the content supplied within the element is less.
  • The min-width property doesn't work if the content is larger than the minimum width.
  • The CSS min width property takes keyword values such as auto, max-content, min-content, etc.
  • It supports numeric values such as length in px, em, and percentage.
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more