MediaWiki talk:Gadget-StickyTableHeaders.css

"and firefox's sticky support seems completely broken"
It's not completely broken, but it doesn't currently work on table cells much like how you point out that Chrome's support doesn't work on. It looks like the upstream bug for that is 975644. Anomie⚔ 14:55, 28 March 2017 (UTC) Testing... ... ... ... ... ... ... ... ... ...

Div Header ... ... ... ... ... ... ... ... ... ... Div Footer

... ...

... ... ... ... ... ... ... ... ... ...

Firefox 59 supports sticky headers
I know the change was made a while ago in the gadget, but release channel Firefox 59 only popped out this week. Yay! You might consider tweaking the gadget description, which says it requires Safari or Chrome.

However, it looks like Timeless doesn't play well with it? No headers are sticky. :( Vector works. --Izno (talk) 23:01, 17 March 2018 (UTC)
 * Still clobbers borders too, but that's a minor offense. --Izno (talk) 23:02, 17 March 2018 (UTC)
 * Is it that no headers are sticky, or that they "stick" underneath Timeless's own non-scrolling page header where they're not normally visible? Anomie⚔ 14:17, 18 March 2018 (UTC)
 * It looked to me (with two rows with of headers, one of which was two lines, ref test page) that they weren't sticky, not that Timeless was clobbering them. I haven't tried with three or four rows of headers. --Izno (talk) 16:22, 18 March 2018 (UTC)
 * Headers now sticky in Timeless. Yay. However, references apparently have a higher z-level, so the headers end up displaying with references in front. Firefox 60.0.2. Found this one on ...Baby One More Time (song). --Izno (talk) 14:44, 14 June 2018 (UTC)
 * So, the headers are sticky but there's something going on with some weird whitespace displayed only in monitor resolutions. (At sub-monitor resolution, no issue.) The change corresponded with a Thursday deploy I'd guess. --Izno (talk) 18:07, 28 October 2018 (UTC)
 * The heights were changed some while ago in Timeless. At least in Firefox, 3.3em fits a lot better for me in the resolutions above 1100px rather than the 6em in the current gadget (the whitespace above is not actually whitespace but the 'background' of the rest of the page). (The 850px-1100px region is still fail.) Would one of you mind adjusting that and/or checking Safari? --Izno (talk) 01:20, 22 November 2018 (UTC)

Bug: rowspan in headers does not propagate into table
As found at Help talk:Table, code such as:

b !c

does not leave space for column 2 in row 2 (where "b" should spread due to ), but instead "z" is immediately adjacent to "x" and the third cell in row 2 is blank. DMacks (talk) 19:30, 28 June 2018 (UTC)
 * Well that's not what you are supposed to do with tables. If you stand on your head, things will be upside down. ;) —Th e DJ (talk • contribs) 00:46, 29 June 2018 (UTC)
 * It's an example from Help:Table. And it gives valid HTML and renders correctly with the gadget off and does not appear to be forbidden or recommended against in the standards. DMacks (talk) 02:37, 29 June 2018 (UTC)
 * Tables are also used to layout entire pages. also allowed, renders, just not what they were made for. —Th e DJ (talk • contribs) 07:53, 29 June 2018 (UTC)

So, I've been working to understand 's argument about why the markup in question is "wrong", and after a lot of investigation, I have to say: I agree. The issue comes down to how the table renders into HTML, and then how the browser in turn parses that HTML. While the table "looks right" with the sticky-tables gadget turned off, that's only by pure luck, because it's already in an invalid state within the browser's DOM tree. Turning on the gadget merely exposes that invalid state. Using Special:ExpandTemplates, here's the raw HTML for that example table above:

But the real problem comes in when Chrome (or any standards-compliant browser) parses that HTML. Because the first row is made entirely of cells, the browser wraps a  around that row. The second row, being that it only contains body cells, goes into. Which means that the and  are not discrete, because the middle cell occupies both. That's invalid. And since the gadget manipulates the block of the table, when it's enabled the rendering of that invalid structure breaks.

In the HTML, the table can be corrected by converting the into. When that's done, there are no longer any pure header rows in the table, so the table is parsed as having an empty  and the entire structure in the. That's perfectly valid, and displays correctly even with the gadget enabled:

Wikitable syntax doesn't allow mixing regular data cells into column header rows — when a row starts with, all of the cells are header cells even if they have   separators. But, it does allow data rows with header cells mixed into them, via. Which means that a version of our original nonrectangular table example from Help:Table which is fully compatible with the gadget would look like this:

{

Here again, the table is parsed by the browser as having an empty. The entire structure is enclosed in the, which means it's ignored by the sticky-headers gadget. -- FeRD_NYC (talk) 12:33, 5 July 2018 (UTC)


 * In fact, I just tested and the same thing works, and renders correctly, if  is used on the header cells instead of  . Which is arguably more correct semantically, since the header cells are meant to apply to their column. -- FeRD_NYC (talk) 12:54, 5 July 2018 (UTC)

Borders in sticky headers
 Border=1  is in HTML5.  Rules=all  and  cellpadding=x  are not. Just wondering if any of this might help.

{| class=wikitable

{|

{| border=1

 {| rules=all 

{| border=1 rules=all

{| border=1 rules=all cellpadding=3

It looks like  rules=all  might somehow solve the header borders problem. -- Timeshifter (talk) 22:36, 31 May 2019 (UTC)

border-collapse works and is HTML5 compliant
I forgot to mention I am using Firefox.

is also HTML5 compliant, and must also be used for this to work.

{| border=1 style=border-collapse:collapse;

By the way, for those who don't know, the table is from the "insert a table" button on the 2006 editing toolbar. A similar table can be had from clicking the table button in the advanced menu of the 2010 editing toolbar.

See: Special:Preferences. There one can enable this:
 * Enable the editing toolbar. This is sometimes called the '2010 wikitext editor'.

I normally have the 2006 editing toolbar (plus extensions) enabled. I have the following 3 gadgets enabled in the editing section of gadget preferences:
 * Enable the legacy (2006) editing toolbar. This will be overridden by the "Enable the editing toolbar" option in the Editing tab.
 * refToolbar: add a "cite" button to the editing toolbar for quick addition of commonly used citation templates
 * Add extra buttons to the old (non-enhanced) editing toolbar

They just add more buttons to the 2006 editing toolbar. Unfortunately, both toolbars can not be enabled at the same time. The 2010 preference will override the 2006 preference setting. --Timeshifter (talk) 09:26, 1 July 2019 (UTC)

Row headers in sticky
You might want to take a look at what turning stick on does to the row headers in this table in Firefox. As you scroll up the page, the row headers in the bottom half of the table start to overlap and obscure those in the top of the table. SpinningSpark 18:27, 2 May 2020 (UTC)

This is expected. The table is not complete. The script that enhances the functionality tries to build thead/tfoot's by looking at if a row consists solely of th cells, which these last rows do. It does't do an entire cell count on the table to figure out if the table is wellformed (tablesorter DOES do this, but it's way more advanced in how it analyzes tables). —Th e DJ (talk • contribs) 14:02, 1 September 2021 (UTC)

Sticky headers not working with scrollable tables (Timeless)
So, it doesn't work with Timeless anymore. While I'm really not sure how to fix this, from a brief investigation, it looks like the issue is with the css - position:sticky appears to not play well with overflow:hidden/scroll or some such, for whatever reason?

Dunno, but I'm about to have entirely too much fun attempting to implement sticky scrollbars, and as a result of this rather stupid limitation that might just need to go full CodeMirror... mind you, if this actually does turn out to work, that might actually be the way to go here for better cross-skin and -browser support anyway. Maybe. -— Isarra ༆ 21:04, 14 December 2020 (UTC)


 * See also: Help talk:Table. It has some recent comments, links, and examples. --Timeshifter (talk) 00:41, 16 December 2020 (UTC)

Request update
Request to update the CSS of this gadget to the below source. This should enable the code on Chrome, but more importantly should deal with the issue of missing borders in the sticky content. It also Also please update MediaWiki:Gadget-StickyTableHeaders to read: Make sure that headers of tables remain in view as long as the table is in view (requires Chrome 91+, Firefox v59+ or Safari) Thank you, —Th e DJ (talk • contribs) 13:58, 1 September 2021 (UTC)


 * Ping me if I don't get to this in the next day or two. IznoPublic (talk) 02:15, 10 September 2021 (UTC)
 * ✅ Izno (talk) 03:29, 10 September 2021 (UTC)

Interface-protected edit request on 23 July 2022
Please add the following before line 24, to let the sticky table headers take into account the sticky vector header —Th e DJ (talk • contribs) 11:48, 23 July 2022 (UTC)
 * ✅ — xaosflux  Talk 12:01, 23 July 2022 (UTC)

Error on table wrapped in style="overflow:auto"
An issue with 2022–23 NCAA Division I women's basketball rankings was reported at Village pump (technical). In Vector 2022 the contents of the header row moves down on top of the next row when the gadget runs. Also, the header is not sticky but remains on top of the next row. The table is made with ColPollTable. Special:ExpandTemplates shows that the produced table code is wrapped in. If this code is removed then the table appears to display correctly. PrimeHunter (talk) 01:46, 4 February 2023 (UTC)


 * Yes this is a known problem with sticky. Sticky is always relative to the first scrollcontext. So if you wrap something in an overflow:auto, your headers become relative to that, instead of the rest of the page, yet its offset is still the sticky skin header. This is one of the reasons why adding sticky headers is so problematic. —Th e DJ (talk • contribs) 10:22, 4 February 2023 (UTC)
 * i'm wondering if CSS4 container queries could help solve that.. Something worth experimenting with. —Th e DJ (talk • contribs) 10:48, 4 February 2023 (UTC)
 * In Vector Legacy it isn't sticky either but it's displayed in the right place at top of the table and not on top of the next row. It would be nice to at least get that in Vector 2022. PrimeHunter (talk) 15:14, 4 February 2023 (UTC)
 * Legacy vector doesn’t have a sticky toolbar to take into account on the offset —Th e DJ (talk • contribs) 22:51, 4 February 2023 (UTC)

Proposal to add toggle
The gadget is great on many long tables but some tables display incorrectly or poorly so I haven't enabled it. Also, as an editor I often want to see what normal readers see. I have made a script User:PrimeHunter/Sticky headers.js which adds a link under "Tools" to reload the current page with the gadget code, for users who haven't enabled the gadget. I propose the gadget itself adds a disable/enable toggle, maybe only for the current page, or maybe remembering the setting until the next click. PrimeHunter (talk) 01:02, 15 February 2023 (UTC)
 * Agreed; that would be a nice enhancement. Mathglot (talk) 18:34, 19 March 2023 (UTC)

Sticky headers on smartphone browsers
Hey, I tried the sticky headers on the smartphone browsers of Firefox and Free Adblock browsers. Both browsers don't show the sticky headers in the mobile view of Wikipedia.

While the browser on my desktop PC shows the sticky headers in both the desktop and mobile view of WP.

https://en.wikipedia.org/wiki/List_of_Airbus_A320_family_operators

Can you make the sticky browsers work on smartphone browsers? :) WikiPate (talk) 15:38, 15 October 2023 (UTC)

Set to the sticky header
If there are absolutely-positioned elements like at Corruption Perceptions Index, the header ends up like this:

This seems to be easily fixed by setting  to the header (not sure about the value). Jack who built the house (talk) 10:09, 28 April 2024 (UTC)

Not working at The Economist Democracy Index
And also it distorts the table header: Jack who built the house (talk) 17:45, 4 May 2024 (UTC)
 * It works currently but failed at the time of the post. It happened because the table was wrapped in . It also happens for Series overview which wraps the table in   and is used in 8000 pages, e.g. List of Downton Abbey episodes. It isn't sticky in any skin but it's worse in Vector 2022 and Timeless where the header rows are moved down by the gadget and cover some of the following rows as shown in File:English Wikipedia The Economist Democracy Index 2024-05-04 17-43-31.png. I don't know how to fix it. PrimeHunter (talk) 11:18, 16 July 2024 (UTC)