Why doesn't Tailwind CSS's w-full fill the parent container?

May 5, 2025

On the afternoon of May 5, I added a sidebar to AssetMan's action management page to switch between the action log, running actions, and managing actions. I wanted the page to fill its outer <main> even when I switched to a section with little content. The page already had w-full, and the content area on the right had flex-1. Why did the contents still influence its width? My search at the time was tailwind take up all space in partent container.1

Later, I pasted the parent and child tags into Cursor. I had already added min-w-[80vw] to <main> so it would take up at least 80% of the browser viewport. That narrowed the question to its immediate child: the same div had both container and w-full.

w-full sets width: 100%. That percentage is calculated from the parent's content box. But container also sets a maximum width on the div, and the limit changes at different breakpoints. If <main> offers more room than the current limit, the div stops growing at that limit. The flex-1 area on the right can take only the space left inside that layer after the sidebar gets its share.2

In my May 6 commit, I kept the minimum width on <main> and changed one line in the action management page's outer wrapper.3

-    <div className="container mx-auto p-4 w-full">
+    <div className="p-4 w-full">

mx-auto had centered the wrapper horizontally. The class limiting its width was container. Once I removed it, w-full could use all the width <main> made available to the page. The w-full that later appeared on the right-hand content area came from a separate change on May 20.4

Footnotes

  1. Cai, B. (2025, May 5). Add navigation drawer for sections of action management [Commit e36b89b]. GitHub. Sidebar and content area in ActionManagement.jsx ↩

  2. Tailwind Labs. (n.d.). Max-width. Tailwind CSS. Using breakpoints container ↩

  3. Cai, B. (2025, May 6). Add feature display user nickname and text avatar on top nav bar; other UI adjustments [Commit ee6036b]. GitHub. Changes to App.jsx and ActionManagement.jsx ↩

  4. Cai, B. (2025, May 20). Enhance some UI details to make user experience more delightful [Commit d654ba3]. GitHub. Later changes to ActionManagement.jsx ↩

© 2025 borui. All rights reserved. This content may be freely reproduced, displayed, modified, or distributed with proper attribution to borui and a link to the article: borui (2025-05-05). Why doesn't Tailwind CSS's w-full fill the parent container?. https://caiborui.com/blog/2025-05-05-zh-tailwind-w-full-container-max-width-entrans

@misc{borui2025-042fa737,
  author = {borui},
  title = {{Why doesn't Tailwind CSS's w-full fill the parent container?}},
  year = {2025},
  publisher = {borui's blog},
  url = {https://caiborui.com/blog/2025-05-05-zh-tailwind-w-full-container-max-width-entrans}
}