Categories: CSSScriptWeb Design

Convert Sectioned Contents Into Tabs – tinytabs

An ultra-light, zero-dependency JavaScript library that converts the long & large sectioned contents into user-friendly tabs.

The library automatically generates tab navigation from heading elements (h3) and the users are able to switch between sectioned content by clicking the tabs.

It also automatically generates hashtags from tab IDs so that you can easily and directly access to certain tabbed content through URL.

Table of Contents

Toggle

How to use it:

Add content sections to the page.

<div id="mytabs">
  <div class="section" id="example">
    <p>
     This is Tab 1
    </p>
    <h3 class="title">Tab 1</h3>
  </div>

  <div class="section" id="more">
    <h3 class="title">Tab 2</h3>
    <p>
      This is Tab 2
    </p>
  </div>

  <div class="section" id="video">
    <h3 class="title">Tab 3</h3>
    <iframe width="560" height="315" src="https://www.youtube.com/embed/UBa-EtVvSks" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
  </div>
</div>

Download and insert the tinytabs’ JavaScript and CSS files into the HTML.

<link rel="stylesheet" href="src/tinytabs.css" />
<script src="src/tinytabs.js"></script>

Initialize the tabs on document ready,

document.addEventListener("DOMContentLoaded", function(e) {
  tinytabs(document.querySelector("#mytabs"));
});

Enable/disable hashtags in the URL. Default: true.

document.addEventListener("DOMContentLoaded", function(e) {
  tinytabs(document.querySelector("#mytabs"), {
    anchor: true
  });
});

Show/hide the title. Default: true.

document.addEventListener("DOMContentLoaded", function(e) {
  tinytabs(document.querySelector("#mytabs"), {
    hideTitle: true
  });
});

Default CSS selectors.

document.addEventListener("DOMContentLoaded", function(e) {
  tinytabs(document.querySelector("#mytabs"), {
    sectionClass: "section",
    tabsClass: "tabs",
    tabClass: "tab",
    titleClass: "title",
    selClass: "sel"
  });
});

Changelog:

v3.0.0 (05/02/2025)

  • tabs close feature

06/21/2020

  • JS update

The post Convert Sectioned Contents Into Tabs – tinytabs appeared first on CSS Script.

rssfeeds-admin

Share
Published by
rssfeeds-admin

Recent Posts

Agreement With Toll Road Operator

FORT WAYNE, Ind. (WOWO) — The state of Indiana has agreed to let the Indiana…

41 minutes ago

Multiple Storm Rounds

FORT WAYNE, Ind. (WOWO) — Severe thunderstorms are expected to move across central Indiana in…

41 minutes ago

Universal Pictures at CinemaCon 2026: Everything Revealed

Universal Pictures and Focus Features have taken the stage at CinemaCon. We're expecting new looks…

41 minutes ago

Tax Day 2026: Democrats and Republicans battle over impact of new Trump tax cuts

Maritza Montejo, a Liberty Tax Service office manager, helps Aurora Hernandez, left, with her taxes…

46 minutes ago

Union Accuses Rockford Schools of Ignoring Bilingual Class Size Law

The Rockford Education Association is accusing Rockford Public Schools 205 of unfair labor practices. The…

1 hour ago

Severe storms cause extensive damage in Pearl City, Illinois

Severe storms from Tuesday, April 14, caused significant damage in Pearl City, Stephenson County, including…

1 hour ago

This website uses cookies.