--- title: Tabs description: Tabs are elements that help you organize and navigate multiple documents in a single container. They can be used for switching between items in the container. video: '8FtJRXPF5Cs' sass: scss/components/_tabs.scss js: js/foundation.tabs.js --- ## Basics There are two pieces to a tabbed interface: the tabs themselves, and the content for each tab. The tabs are an element with the class `.tabs`, and each item has the class `.tabs-title`. Each tab contains a link to a tab. The `href` of each link should match the ID of a tab. Alternatively, the ID can be specified with the attribute `data-tabs-target`. ```html ``` The tab content container has the class `.tabs-content`, while each section has the class `.tabs-panel`. Each content pane also has a unique ID, which is targeted by a link in the tabstrip.

Watch this part in video

edit on codepen button
```html

Vivamus hendrerit arcu sed erat molestie vehicula. Sed auctor neque eu tellus rhoncus ut eleifend nibh porttitor. Ut in nulla enim. Phasellus molestie magna non est bibendum non venenatis nisl tempor. Suspendisse dictum feugiat nisl ut dapibus.

Suspendisse dictum feugiat nisl ut dapibus. Vivamus hendrerit arcu sed erat molestie vehicula. Ut in nulla enim. Phasellus molestie magna non est bibendum non venenatis nisl tempor. Sed auctor neque eu tellus rhoncus ut eleifend nibh porttitor.

``` Put it all together, and we get this:

one

Check me out! I'm a super cool Tab panel with text content!

I am a link but don't do anything

two

three

Check me out! I'm a super cool Tab panel with text content!

four

five

Check me out! I'm a super cool Tab panel with text content!

six

--- ## Vertical Tabs Add the `.vertical` class to a tabstrip to stack tabs vertically. You can also place the tabstrip and the tab contents in a grid to make them sit side-by-side.

Watch this part in video

edit on codepen button
```html_example

One

Check me out! I'm a super cool Tab panel with text content!

Two

Three

Check me out! I'm a super cool Tab panel with text content!

Four

Five

Check me out! I'm a super cool Tab panel with text content!

Six

``` --- ## Collapsing Tabs Add the attribute `data-active-collapse="true"` to a tabstrip to collapse active tabs.
edit on codepen button
```html_example

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Vivamus hendrerit arcu sed erat molestie vehicula. Sed auctor neque eu tellus rhoncus ut eleifend nibh porttitor. Ut in nulla enim. Phasellus molestie magna non est bibendum non venenatis nisl tempor. Suspendisse dictum feugiat nisl ut dapibus.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

``` --- ## Tabs and URLs ### Browser history When the `data-deep-link` option is set to `true`, the current state of the tabset is recorded by adding a hash with the tab panel ID to the browser URL when a tab opens. By default, tabs *replace* the browser history (using `history.replaceState()`). Modify this behavior by using attribute `data-update-history="true"` to *append* to the browser history (using `history.pushState()`). In the latter case the browser back button will track each click that opens a tab panel. By using deep linking (see below), the open state of a page's tabset may be shared by copy-pasting the browser URL. ### Deep linking Add the attribute `data-deep-link="true"` to a tabstrip to: - modify the browser history when a tab is clicked - allow users to open a particular tab at page load with a hash-appended URL

Watch this part in video

```html_example

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Vivamus hendrerit arcu sed erat molestie vehicula. Sed auctor neque eu tellus rhoncus ut eleifend nibh porttitor. Ut in nulla enim. Phasellus molestie magna non est bibendum non venenatis nisl tempor. Suspendisse dictum feugiat nisl ut dapibus.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

``` For example, http://example.com/#panel3d will open the third tab panel at page load. This example will open a new browser tab and scroll you to the open tab. When linking directly to a tab panel, it might not be obvious that the content appears within a tab panel. An additional attribute `data-deep-link-smudge` rolls the page up slightly after deep linking (to a horizontal tabset) so that the tabstrip is at the top of the viewport. ```html_example