See the Width section of Help:Table. This example table needs to be on this separate page in order to test it more easily in narrower browser windows. Test it in both desktop and mobile views (on cell phones in portrait orientation). See the mobile or desktop view link at the bottom of this Wikipedia page. Use a cell phone to get the true mobile view.
In desktop view on a PC narrow your browser window. On a Wikipedia page that has only text (no tables) a horizontal scrollbar will show up well before the text is unable to wordwrap further. For example see this sandbox. "Lorem ipsum ..." is from here.
A CSS width setting for the overall table in desktop view acts like width settings on divs and tables on webpages outside Wikipedia. Horizontal scrollbars are created when narrowed enough. See width outside Wikipedia:
In mobile view on Wikipedia width and max-width settings on the table as a whole are ignored altogether. In mobile view all the tables below narrow without forming horizontal scrollbars. This is different from tables on webpages outside Wikipedia. Overall table widths (as opposed to max-widths) do not narrow on most pages outside Wikipedia. See max-width outside Wikipedia:
Experiment with em and other width settings on another page outside Wikipedia:
CSS width on table header cell
CSS width for table header cell acts like a max-width setting on desktop, and so it shrinks as browser window shrinks. It shrinks proportionally on mobile, too. No scrollbar in either mode.
Center header width setting:
! Left !! style=width:40em | Center !! Right
Left | Center | Right |
---|---|---|
Top left cell | Top center cell | Top right cell |
Middle left cell | Middle center cell | Middle right cell |
Bottom left cell | Bottom center cell | Bottom right cell |
CSS width on table as a whole
CSS width for overall table width works on desktop (scrollbar if narrow enough), and is ignored altogether on mobile.
Overall table width:
{| class=wikitable style=width:50em
Left | Center | Right |
---|---|---|
Top left cell | Top center cell | Top right cell |
Middle left cell | Middle center cell | Middle right cell |
Bottom left cell | Bottom center cell | Bottom right cell |
CSS max-width on a table cell
CSS max-width for a table cell works on both desktop and mobile. And it shrinks further as screen or browser narrows. Portrait versus landscape view on cell phone.
| Bottom left cell || Bottom center cell || style=max-width:40em; |"Lorem ipsum ...
Left | Center | Right |
---|---|---|
Top left cell | Top center cell | Top right cell |
Middle left cell | Middle center cell | Middle right cell |
Bottom left cell | Bottom center cell | "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." |
CSS max-width on table as a whole
CSS max-width for overall table width works on both desktop and mobile. And it shrinks further as screen or browser narrows. Portrait versus landscape view on cell phone.
Overall table width attempted via max-width:
{| class=wikitable style="max-width:40em;"
Left | Center | Right |
---|---|---|
Top left cell | Top center cell | Top right cell |
Middle left cell | Middle center cell | Middle right cell |
Bottom left cell | Bottom center cell | "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." |