How to Create Full-Page Tabs using CSS & JavaScript? Last Updated : 14 May, 2024 Comments Improve Suggest changes Like Article Like Report Tabs are a common UI pattern used to organize content into multiple sections within a single page. In this article, we'll explore how to create full-page tabs using CSS and JavaScript. Full-page tabs allow users to switch between different sections of content while maintaining a clean and intuitive user interface. Approach:Set up a container with tab headers and corresponding tab content sections.Apply CSS styles to the tabs and set the height of the tab content to fill the viewport for a visually appealing layout.Implement a function to handle tab switching dynamically based on user clicks.Attach the tab-switching function to the onclick event of each tab header to enable interactivity.Toggle the "active" class on the tab content sections to show the selected tab while hiding others for seamless user experience.Consider adding transitions or animations to improve the visual feedback when switching between tabs for a polished user interface.Example: Implementation to design full-page tabs using CSS and JavaScript HTML <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <link rel="stylesheet" href="style.css"> <body> <div class="container"> <div class="tab-header"> <div class="tab-link" onclick="showTab(0)"> HTML </div> <div class="tab-link" onclick="showTab(1)"> CSS </div> <div class="tab-link" onclick="showTab(2)"> JavaScript </div> <div class="tab-link" onclick="showTab(3)"> React </div> </div> <div class="tab-content active"> <h1>HTML</h1> <p> HTML, which stands for <span>Hyper Text Markup Language</span>, is the standard markup language for creating web pages. It describes the structure of a web page semantically and is the first language you learn when diving into web development. </p> </div> <div class="tab-content"> <h1>CSS</h1> <p> CSS, which stands for <span>Cascading Style Sheets</span>, is used to style the layout of a web page. It enables you to control the appearance of your HTML elements, including colors, fonts, margins, and more. </p> </div> <div class="tab-content"> <h1>JavaScript</h1> <p> JavaScript is a high-level, interpreted programming language that adds interactivity and dynamic behavior to web pages. With JavaScript, you can manipulate HTML and CSS, handle user events, and communicate with servers to create powerful web applications. </p> </div> <div class="tab-content"> <h1>React</h1> <p> React is a JavaScript library for building user interfaces. It allows you to create reusable UI components and manage the state of your application efficiently. React's declarative syntax and component-based architecture make it easy to ' build complex web applications with ease. </p> </div> </div> <script src="script.js"> </script> </body> </html> CSS body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin: 0; padding: 0; background-color: #f5f5f5; color: #333; } .container { max-width: 100vw; margin: 0 auto; background-color: #fff; border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); overflow: hidden; height: 100vh; } .tab-header { display: flex; } .tab-link { flex: 1; padding: 15px; text-align: center; cursor: pointer; background-color: #4CAF50; color: white; transition: background-color 0.3s ease; } .tab-link:hover { background-color: #45a049; } .tab-content { padding: 30px; display: none; height: 100vh; overflow-y: auto; } .active { display: block; } h1 { font-size: 24px; margin-bottom: 15px; color: #4CAF50; } p { line-height: 1.6; } span { color: #FF5722; } JavaScript function showTab(index) { // Retrieve tab content elements let tabContents = document.getElementsByClassName("tab-content"); // Loop through all tab content elements for (let i = 0; i < tabContents.length; i++) { // Remove the "active" class from all tab content elements tabContents[i].classList.remove("active"); } // Add the "active" class to the tab // content element at the specified index tabContents[index].classList.add("active"); } Output: Output Comment More infoAdvertise with us Next Article How to Create Full-Page Tabs using CSS & JavaScript? A anuvam9263 Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Questions Similar Reads Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co 11 min read JavaScript Tutorial JavaScript is a programming language used to create dynamic content for websites. It is a lightweight, cross-platform, and single-threaded programming language. It's an interpreted language that executes code line by line, providing more flexibility.JavaScript on Client Side: On the client side, Jav 11 min read Web Development Web development is the process of creating, building, and maintaining websites and web applications. It involves everything from web design to programming and database management. Web development is generally divided into three core areas: Frontend Development, Backend Development, and Full Stack De 5 min read Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance 10 min read Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact 12 min read React Interview Questions and Answers React is an efficient, flexible, and open-source JavaScript library that allows developers to create simple, fast, and scalable web applications. Jordan Walke, a software engineer who was working for Facebook, created React. Developers with a JavaScript background can easily develop web applications 15+ min read Steady State Response In this article, we are going to discuss the steady-state response. We will see what is steady state response in Time domain analysis. We will then discuss some of the standard test signals used in finding the response of a response. We also discuss the first-order response for different signals. We 9 min read JavaScript Interview Questions and Answers JavaScript (JS) is the most popular lightweight, scripting, and interpreted programming language. JavaScript is well-known as a scripting language for web pages, mobile apps, web servers, and many other platforms. Both front-end and back-end developers need to have a strong command of JavaScript, as 15+ min read React Tutorial React is a JavaScript Library known for front-end development (or user interface). It is popular due to its component-based architecture, Single Page Applications (SPAs), and Virtual DOM for building web applications that are fast, efficient, and scalable.Applications are built using reusable compon 8 min read Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and 9 min read Like