How to add tabs in HTML

Tabs are perfect for single-page web applications or for web pages capable of displaying different subjects. We all use tabs when designing websites – a website may have many tabs to provide different information to users. In HTML, tabs are created like they are buttons. Look at the implementation below to understand it further.

Code

In the code above, we use the reference id to refer to the tab. Tab content can be viewed as part of the id having tab1, tab2, and tab3, respectively. Once we have successfully defined the references and their specific content, we use simple JavaScript to manipulate the output to our preferences. Whenever any tab is clicked, the opentab function is called, which takes data and links from the tab using their id and uses the active module to ensure that only specific information of that tab is displayed.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved