Content deleted Content added
Timeshifter (talk | contribs) Update info |
Favre1fan93 (talk | contribs) |
||
(28 intermediate revisions by 3 users not shown) | |||
Line 1:
__TOC__
See the '''[[Help:Table#Width|Width]]''' section of [[Help:Table]].
These example tables need to be on this separate page in order to test them more easily in narrower browser windows. Test them 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) the page can only be narrowed so far before a horizontal scrollbar appears. ▼
▲In desktop view on a PC '''narrow your browser window.''' On a Wikipedia page that has '''only text (no tables)'''
*[https://www.w3schools.com/cssref/pr_dim_width.php CSS width Property].▼
== Line breaks ==
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:▼
*[https://www.w3schools.com/css/css_dimension.asp CSS Height, Width and Max-width].▼
Line breaks '''<nowiki><br></nowiki>''' are OK to narrow header cells, and other cells. See Graham87 comments at [[Help talk:Table/Advanced#Line breaks in table cells]].
Experiment with em and other width settings on another page outside Wikipedia: ▼
*[https://www.w3schools.com/html/html_table_sizes.asp HTML Table Sizes].▼
==
'''{{tlx|shy}}''' can be placed in long header words like "population" to add a [[soft hyphen]] when the screen is narrow (as on portrait view on cell phones):
;Wikitext
:<code><nowiki>popu{{shy}}lation</nowiki></code>
;Which appears as
: population
;Except in narrow screens where it looks like this:
:popu-<br>lation
== CSS max-width on table as a whole ==
'''Center header width setting:'''▼
{{hatnote|'''Note:''' "Lorem ipsum ..." is from [https://www.lipsum.com here].}}
:<code>! Left !! style=width:40em | Center !! Right</code>▼
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.
{| class=wikitable style="max-width:40em;"
|-
! Left !! Center !! Right
|-
|-
| 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 header cells ==
See examples at [[Help:Table#Width]].
== 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.
:<code>| Bottom left cell || Bottom center cell || style=max-width:40em; |"Lorem ipsum ...</code>
{| class=wikitable
|-
! Left !!
|-
| Top left cell || Top center cell || Top right cell
Line 29 ⟶ 57:
| Middle left cell || Middle center cell || Middle right cell
|-
| Bottom left cell || Bottom center cell || style=max-width:40em; |"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."
▲| Bottom left cell || Bottom center cell || Bottom right cell
|}
== CSS width
A CSS width setting for the overall table in '''desktop view''' acts like width
*[https://developer.mozilla.org/en-US/docs/Web/CSS/width width - CSS: Cascading Style Sheets | MDN]
▲*[https://www.w3schools.com/cssref/pr_dim_width.php CSS width Property].
▲In '''mobile view''' on Wikipedia
▲*[https://www.w3schools.com/css/css_dimension.asp CSS Height, Width and Max-width].
▲Experiment with em and other width settings on another page outside Wikipedia:
▲*[https://www.w3schools.com/html/html_table_sizes.asp HTML Table Sizes].
== Example. CSS width on table as a whole ==
CSS width for overall table width works on desktop ('''horizontal scrollbar''' if screen is too narrow for width setting). It is ignored altogether on these iPhone browsers: Edge, Chrome, Firefox, Opera. But not on iPhone Safari where it works the same as on desktop.
:<code>{| class=wikitable style=width:50em</code>
Line 50 ⟶ 90:
|}
== CSS
CSS
▲'''Overall table width attempted via max-width:'''
:<code>
{| class=wikitable
|-
! Left !! style=width:40em | Center !! Right
|-
| Top left cell || Top center cell || Top right cell
Line 65 ⟶ 105:
| Middle left cell || Middle center cell || Middle right cell
|-
| Bottom left cell || Bottom center cell || Bottom 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."
|}
|