Template:Sticky header and Template talk:Sticky header

Simple table with subsection header edit

Complex header with table subsection headers edit

A complex multi-row header with rowspan and colspan.

See: Renewable energy in the United States#Renewable energy in the electricity sector. Scroll down to the table titled: "Composition of renewable electricity production" See this version of the article.

A blank row had to be added between the top table header and the first subsection header in order to prevent the first table subsection header from being sticky. See lines 18-19 in the wiki source excerpt below. Scroll down into the table to see that none of the subsection headers stick.

Wiki source excerpt:

{{mw-datatable}}{{sticky header}}{{sort under}}
{| class="wikitable sortable plainrowheaders mw-datatable sticky-header sort-under"
|+ Composition of renewable electricity production (2018–2019)
|- 
! scope="col" rowspan=2| Power source
! scope="col" rowspan=2| Summer<br> capacity (GW)
! scope="col" colspan=2| Share of
! scope="col" rowspan=2| Capacity<br> factor
! scope="col" rowspan=2| Energy<br> generation (TWh)
! scope="col" colspan=2| Share of
|-
! scope="col" | renewable 
! scope="col" | total 
! scope="col" | renewable 
! scope="col" | total 
|-
| || || || || || || || 
|-
! scope="col" colspan="8" |'''Preliminary electricity production by renewable sources in 2019'''
|-