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 How to Create Tab Headers using CSS & JavaScript? Tab headers are a commonly used user interface element in web development. They provide a way to organize content into distinct sections, allowing users to switch between them easily. Each tab represents a different category or topic, and clicking on a tab displays the corresponding content while hi 2 min read How to create a Landing page using HTML CSS and JavaScript ? A landing page, also referred to as a lead capture page, static page, or destination page, serves a specific purpose and typically appears as a result of online advertising or search engine optimization efforts. Unlike a homepage, a landing page is stripped of distractions and focuses on capturing v 7 min read Create an Infinite Scroll Page using HTML CSS & JavaScript In this article, we will create an infinite scroll page using HTML, CSS, and JavaScript. Infinite scrolling allows you to load and display content as the user scrolls down the page, providing a seamless browsing experience. We'll fetch and append new content dynamically as the user reaches the end o 2 min read How to Create Full Screen Overlay Navigation Bar using HTML CSS and JavaScript ? Create a full screen Navigation Bar: In this article, you will learn how to create a full-screen navbar for your website. There are three methods to create a full screen overlay navigation bar which are listed below: From Left From top No animation- Just show You will be required to create two divs. 4 min read How to Create a Full-Width Table using CSS? Creating a full-width table using CSS involves setting the table's width to 100% and adjusting other relevant properties to ensure that it stretches across the entire width of its parent container. In this article, we will explain the approach to creating a full-width table using CSS. ApproachCreate 2 min read How to create a revealing sidebar using HTML CSS and JavaScript? A revealing sidebar is a hidden UI element that becomes visible upon user interaction, such as clicking or swiping, providing navigation links. The content of the page will rotate and the navigation bar will reveal itself when the menu button is clicked. ApproachCreate an HTML file with headings and 3 min read How to Create Horizontal and Vertical Tabs using JavaScript ? In this article, we will create Horizontal and Vertical Tabs using JavaScript.Tabs can be used for displaying large amounts of content on a single page in an organized manner. We can design single-page tabs using HTML, CSS, and JavaScript. HTML elements are used to design the structure of the tabs a 7 min read How to Change Tabs on Hover with CSS and JavaScript ? In this article, we are going to learn how can we change tabs on hover, with CSS and JavaScript. Changing tabs on hover enhances the user experience by offering interactive hover navigation. Users can quickly preview different sections without clicking which reduces the time it takes to explore diff 4 min read How to Create Sticky Header/Footer on a Web Page using HTML CSS and JavaScript? When designing a website, it's essential to consider the sticky header and footer. These elements enhance the user experience by keeping important navigation links accessible as users scroll. This article explores creating sticky headers and footers with CSS.We can do this by using the following CSS 7 min read How to create a smooth scrolling effect using CSS ? Smooth scrolling is employed on web pages to enhance the user experience by providing a visually appealing and seamless transition between different sections of the page. It improves readability and enhances navigation. Using the CSS property scroll-behaviour we can achieve the smooth scrolling effe 2 min read Like