max-width

Limits the maximum width of an element. A core property for container centering, responsive layouts, and content readability. Use maxw + unit combination.

Class List

ClassCSSDescription
maxw{N}pxmax-width: {N}pxpixel-based max-width (under 20px)
maxw{N}remmax-width: {N}remrem-based max-width (20px and above, 1rem=10px)
maxw{N}pmax-width: {N}%percentage-based max-width
maxwamax-width: autoreset to browser default
maxwnmax-width: noneremove max-width limit
maxwfcmax-width: fit-contentfit-content size (does not exceed parent)
maxwmincmax-width: min-contentminimum size based on longest word
maxwmaxcmax-width: max-contentsingle-line size without wrapping

Core Pattern: Center Container

The most commonly used pattern in Atomic CSS. maxw120rem mxa px2rem creates a centered container with a max width of 1200px.

<!-- Most common center container -->
<div class="maxw120rem mxa px2rem">
  <!-- max-width: 1200px, margin: 0 auto, padding: 0 20px -->
  <h1>Page Title</h1>
  <p>Content stays center-aligned without exceeding 1200px</p>
</div>

<!-- Narrow content area (blog, docs) -->
<article class="maxw72rem mxa px2rem">
  <!-- max-width: 720px, Suitable for body text readability -->
  <h1>Article title</h1>
  <p>Comfortable width for about 60-80 characters per line</p>
</article>

<!-- Wide container (dashboard) -->
<div class="maxw160rem mxa px2rem">
  <!-- max-width: 1600px -->
  <div class="dg gtcr4-1fr gap2rem">...</div>
</div>

Center container visualization

maxw40rem mxa px2rem

The outer area spans the full screen; the purple area is constrained by max-width and centered

Class CombinationDescription
maxw120rem mxa px2rem1200px center container (most common)
maxw72rem mxa px2rem720px text area (blog, documentation)
maxw96rem mxa px2rem960px medium container
maxw160rem mxa px2rem1600px wide container (dashboard)
maxw40rem mxa400px narrow area (login form, modal)

Responsive Container

Combine with media query prefixes to apply different max-width values depending on screen size.

<!-- Responsive max-width transition -->
<div class="maxw120rem md-maxw96rem sm-maxw100p mxa px2rem">
  Default 1200px → Tablet 960px → Mobile 100%
</div>

<!-- Remove limit on mobile -->
<div class="maxw80rem sm-maxwn mxa px2rem">
  Default 800px, no limit on mobile
</div>

<!-- Image responsive limit -->
<img class="maxw100p ha db" src="hero.jpg" alt="Responsive Image" />
Class CombinationBehavior
maxw120rem md-maxw96remdefault 1200px, 960px below 1024px
maxw80rem sm-maxwndefault 800px, no limit below 768px
maxw100pdoes not exceed parent 100% width (essential for images)
maxw120rem sm-maxw100pdefault 1200px, 100% on mobile

Content-Based Sizing

Keyword classes that determine max-width based on content instead of fixed values.

fit-content — maxwfc

콘텐츠에 맞는 크기

Fits content size without exceeding parent width

min-content — maxwminc

최소 콘텐츠 크기

Constrained to the width of the longest word

max-content — maxwmaxc

콘텐츠가 줄바꿈 없이 한 줄로 표시되는 크기입니다

Width that fits all content in a single line without wrapping

<!-- fit-content: Fits to content size -->
<div class="maxwfc bg18181B p16px br8px">
  This box fits the text length
</div>

<!-- min-content: Based on longest word -->
<div class="maxwminc bg18181B p16px br8px">
  Long sentence but wraps at word boundaries
</div>

<!-- max-content: Full display without wrapping -->
<div class="maxwmaxc bg18181B p16px br8px">
  This text is displayed in a single line without wrapping
</div>

<!-- none: Remove limit -->
<div class="maxwn bg18181B p16px br8px">
  No max-width limit
</div>

Visual Comparison

Compares how various max-width values affect an element.

max-width: 200px — maxw200px

maxw200px (200px limit)

element width does not exceed 200px

max-width: 50rem (500px) — maxw50rem

maxw50rem (500px limit)

allows up to 500px based on 1rem = 10px

max-width: 100% — maxw100p

maxw100p (parent 100%)

does not exceed parent width; essential for images

max-width: fit-content — maxwfc

maxwfc

width determined by content size

max-width: none — maxwn

maxwn (no limit)

max-width limit fully removed

Tips & Notes

maxw + mxa = center layout

maxw120rem mxa px2rem is the most universal center container pattern. It limits the max width, sets left/right margins to auto, and ensures side padding on mobile.

Auto-sized elements with maxwfc

maxwfc is useful for elements that should auto-size to their content, such as buttons, tags, and badges.

Remove limit with maxwn

When max-width is set by a parent or global style, use maxwn to remove the limit. The sm-maxwn pattern is commonly used for full width on mobile.

Text width limit for readability

Body text is optimal at 60-80 characters per line. Limiting the text area's max width to around maxw72rem (720px) improves readability.