How to create links to sections within the same page in HTML ? Last Updated : 03 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Creating internal links that allow users to jump to specific sections within a webpage is a powerful way to improve user experience. Especially on long pages with extensive content, these anchor links can make navigation more efficient and intuitive. In fact, studies show that around 70% of users prefer websites with easy in-page navigation, as it helps them find relevant information faster without excessive scrolling. In this guide, we’ll explore how to create these jump links using HTML and best practices to implement them effectively.Syntax<a href="#section1">Section 1</a><a>: The anchor tag is used to define a hyperlink.href="#section1": The href attribute specifies the target of the link. In this case, it points to a section id="section1" on the same page.Section 1: The clickable text that appears for the user. When clicked, it will scroll to the section with id="section1".How to Link to Sections Within the Same PageUse the Anchor Tag <a>: In HTML, use the <a> tag to create links within the same page.Assign Unique IDs: Assign unique IDs to different sections of the webpage using the id attribute.Set the href Attribute: Set the href attribute of the anchor tag to “#section1” (replace “section1” with the desired ID) to link to a specific section.Avoid Using Class Names in href: Class names are not unique identifiers and should not be used in the href attribute for internal linking.Example: Below is an example where we divide the webpage into sections using <div>, assign unique IDs to each section, and use <a> tags in the navigation section with href=”#section1″ to enable users to navigate to specific sections with a click. index.html <html> <head> <style> * { margin: 0; padding: 0; } body { width: 100vw; height: 100vh; font-family: Arial, sans-serif; } .section { width: 100%; height: 100vh; /* Full viewport height */ color: white; font-size: 2rem; display: flex; justify-content: center; align-items: flex-start; /* Align text to the top */ text-align: center; padding-top: 80px; /* Adds space to avoid being hidden behind fixed nav */ } .one { background-color: #EF5354; } .two { background-color: #E03B8B; } .three { background-color: #3944F7; } .four { background-color: #38CC77; } .nav { position: fixed; top: 10px; width: 100%; background-color: #333; display: flex; justify-content: center; padding: 10px 0; z-index: 100; } .btn { color: white; background-color: #38CC77; height: 40px; width: 90px; padding: 2px; border: 2px solid black; text-decoration: none; display: inline-block; margin: 0 10px; text-align: center; } </style> </head> <body> <div class="nav"> <a href="#section1" class="btn">Section 1</a> <a href="#section2" class="btn">Section 2</a> <a href="#section3" class="btn">Section 3</a> <a href="#section4" class="btn">Section 4</a> </div> <div class="section one" id="section1"> Section 1: Welcome to the first section! </div> <div class="section two" id="section2"> Section 2: Here’s some content for the second section. </div> <div class="section three" id="section3"> Section 3: More details and information here. </div> <div class="section four" id="section4"> Section 4: Final section with additional content. </div> </body> </html> OutputHow to create links to sections within the same page in HTML ?Code Overview:This HTML code creates a webpage with a navigation bar at the top containing links to different sections of the page. Each section has a unique background color and is 40% of the viewport height. Clicking a navigation button scrolls the user to the corresponding section. The sections are styled with large text and centered content for easy readability.ConclusionCreating anchor links to sections within the same page in HTML is a way to enhance navigation and improve the user experience. By using the id attribute for target sections and the href attribute for linking, you can create seamless navigation for long pages, FAQs, or single-page websites. Additionally, using smooth scrolling and following best practices will ensure that your anchor links are user-friendly and accessible. Comment More infoAdvertise with us J jymnjogiya Follow Improve Article Tags : Web Technologies HTML HTML-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 HTML Tutorial HTML stands for HyperText Markup Language. It is the standard language used to create and structure content on the web. It tells the web browser how to display text, links, images, and other forms of multimedia on a webpage. HTML sets up the basic structure of a website, and then CSS and JavaScript 11 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 React Tutorial React is a powerful JavaScript library for building fast, scalable front-end applications. Created by Facebook, it's known for its component-based structure, single-page applications (SPAs), and virtual DOM,enabling efficient UI updates and a seamless user experience.Note: The latest stable version 7 min read JavaScript Interview Questions and Answers JavaScript is the most used programming language for developing websites, web servers, mobile applications, and many other platforms. In Both Front-end and Back-end Interviews, JavaScript was asked, and its difficulty depends upon the on your profile and company. Here, we compiled 70+ JS Interview q 15+ 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 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