Horizontal Tabs simulates the interface of offline real world being accessed by each computer user. However, implementing tabbed navigation can be quite difficult sometimes, especially for non-developers.

If you are thinking to use the tabbed navigation then you can easily implement it through jQuery. Do you know how? Here, we will discuss how to implement the Horizontal Tabbed Navigation through jQuery. We will also put a highlight to add the implementation of effects like Collapse, Sorting, and Mouseover.
Let us start now from a blank html file. We are adding following default code to it:

[HTML]

jQuery Tabs

[/HTML]

Now, we will link the default jQuery CSS and JS files with our HTML file.

[HTML][/HTML]

This is the time to add the script code to create the tab interface.

[HTML][/HTML]

This is the default script to create the tabs without any effects.
Now, we will create the tabs using ul and li tags, and add the contents in them. For this work, the jquery-ui-1.8.13.custom CSS file have the classes like tabs-1 for 1st Tab, tabs-2 for 2nd tab, and tabs-3 for 3rd tab. You can edit the CSS file to have more classes to create more tabs in your design. Following is the code to create three tabs:

[HTML]

Content for Tab 1
Content for Tab 2
Content for Tab 3

[/HTML]

After merging the complete HTML code will be as following. You can also copy this code for your work.

[HTML]

jQuery Tabs

Welcome to jQuery Tabs

Tabs

Content for Tab 1
Content for Tab 2
Content for Tab 3

[/HTML]

Following will be the output of the tabs created with above code:

Thinking to add the effects in tabs?

Mouseover Effect
You have to add only event: “mouseover” in the scripts code as show below:

[HTML][/HTML]

Remember to remove the previously existing script code with this one. After adding this code, the tabs will toggle on moving a cursor above them.

Collapsible Tabs

Want your tabs to expand and collapse with a click, then replaces the existing tab code with this one:

[HTML][/HTML]

Sorting

Want to allow the visitors to sort the tabs as per their requirements, just add following code.

[HTML][/HTML]

Positioning Tabs on Bottom

Thinking to position the tabs on the bottom of content! For this, you have to add some more customization through style tag, change the script code, and change the HTML code.

Script Code

[HTML][/HTML]

Style sheet Code

[CSS]

[/CSS]

HTML Code

Now, you have to add the above mentioned tabs-bottom class to the div creating tabs.

[HTML]

[/HTML]

Complete code to have tabs on bottom

[HTML]

jQuery Tabs

 

Welcome to jQuery Tabs

Tabs

Content for Tab 1
Content for Tab 2
Content for Tab 3

[/HTML]

Output

Conclusion

The implementation of Horizontal Tabbed Navigation becomes easy with the use of jQuery libraries.

You can make use of above code or download the following demo-jquery-tab.zip file containing the mentioned files below:
jquery-ui-1.8.13.custom.css – contains the code style the tabs.
jquery-ui-1.8.13.custom.min.js – contains code letting the tabs to work.
jquery-1.5.1.min.js – includes the code from jQuery library from Google Ajax APIs.
demo-jquery-tabs.html – has the code for implement default jQuery tabs.
demo-tabs-mouseover.html – has the code to implement jQuery tabs with mouse over effect.
demo-tabs-sort.html – has the code to implement tabs with sort effect.
demo-tabs-collapse.html – has the code to implement the tabs with collapsible effect.
demo-tabs-on-bottom.html – has the code to implement the default jQuery tabs on bottom.

About the Author

author photo

Mirko Humbert

Mirko Humbert is the editor-in-chief and main author of Designer Daily and Typography Daily. He is also a graphic designer and the founder of WP Expert.