Skip to content

Mobile Accordion Footer with Back to Top

Responsive footer whose four link columns collapse into accordion sections on phones, with a region and currency select, a smooth back to top button and a legal row.

Also known as: collapsible footer menu, footer accordion on mobile, back to top button footer, footer with country selector, ecommerce store footer

Mobile Accordion Footer with Back to Top live demo

Open in new tab

Pure CSS code (HTML, CSS, JS)

A responsive website footer in pure CSS and vanilla JavaScript: four link columns on desktop that turn into collapsible accordion sections on phones, a region and currency select, and a smooth back to top button. This mobile footer menu example fits online stores, brand sites and any site with many footer links.

How it works

The root .maf-root contains a short .maf-strip (the end of a page section) and footer.maf-footer. .maf-top holds the brand block (logo, description, contact address, shipping note) and nav.maf-cols with four .maf-col columns.

Every column heading contains two versions of the title: .maf-title (plain text for wide screens) and button.maf-toggle with aria-expanded and aria-controls (for phones). On load the script sets hidden on every .maf-list whose button is collapsed and toggles both values on click. From 768px the CSS hides the buttons, shows .maf-title and forces .maf-list[hidden] to display: block, so all links are visible on desktop without extra JavaScript. Without JavaScript the lists simply stay open.

.maf-select changes the region. The REGIONS object in script.js maps each option value to a support phone number, a tel: link and a free shipping threshold, which update .maf-phone-text, .maf-phone and .maf-shipping-text. .maf-top-btn scrolls to the top with behavior: 'smooth' and moves focus to the element named in data-maf-target. The copyright year in .maf-year is computed in JavaScript.

Customization

  • --maf-accent and --maf-accent-dark on .maf-root: the teal of the logo, icons, back to top button and focus rings.
  • --maf-radius: corner radius of buttons, the select, social icons and the shipping note (8px by default).
  • --maf-bg, --maf-page, --maf-text, --maf-muted and --maf-line: footer background, strip background, text colors and dividers.
  • REGIONS in script.js: add a key with name, currency, phone, tel and free, then add a matching option to .maf-select.
  • data-maf-target on .maf-top-btn: the id of the heading that receives focus after scrolling up.
  • aria-expanded="true" on a .maf-toggle: that section starts open on phones.
  • The 768px media query in style.css: the width where accordions become columns.

Use cases

  • Online stores: shop, help and store links stay compact on phones
  • International shops: visitors switch region and see local support and shipping terms
  • Long pages: the back to top button returns readers to the start
  • Brand and product sites: contact details sit next to the link columns

Accessibility

The links sit in a nav with aria-label="Footer", column titles are h2 headings, and accordion buttons report their state with aria-expanded. Region changes and the jump to the top are announced in a polite live region (.maf-live). Tap targets are at least 40px, social icons carry hidden names in .maf-sr, focus is visible in teal, and smooth scrolling and chevron rotation turn off with prefers-reduced-motion: reduce.

Usage notes

The select only updates the footer; connect it to your store's currency setting in the change handler.

Mobile Accordion Footer with Back to Top at a glance

Framework
Pure CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
fonts.googleapis.com
Layout
Responsive, works on mobile
Category
Footers
License
Free for personal and commercial use

Questions about this template

Can I use the Mobile Accordion Footer with Back to Top code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load fonts.googleapis.com from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap">
Mobile Accordion Footer with Back to Top – free Pure CSS footer template
Mobile Accordion Footer with Back to Top · free Pure CSS footer template

More Footers

Simple Centered Footer – free Pure CSS footer template

Simple Centered Footer

Minimal centered footer in pure CSS with a logo, tagline, links with animated underlines, round icon links and an auto-updating copyright year.

Multi-Column Footer – free Tailwind CSS footer template

Multi-Column Footer

Dark Tailwind CSS website footer with brand block, social icons, four labelled link columns and a bottom bar with copyright and status.

Dark Footer with App Badges – free Tailwind CSS footer template

Dark Footer with App Badges

Dark Tailwind CSS footer with four link columns, App Store and Google Play badges, and a language select that remembers the choice.

Footer with Newsletter – free Bootstrap 5 footer template

Footer with Newsletter

Dark Bootstrap 5 footer with a newsletter signup panel, email validation, social icons, three link columns and a legal bar.