How to Add Internal HTML Links?

Learn via video course
FREE
View all courses
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
Topics Covered

An internal link is an HTML link placed in the reference with the same webpage. In simple words, an internal link will navigate the user to a part of the same webpage.

The value specified inside the href of an internal link can be absolute or relative. It contains a hash sign(#) and the name of the id to refer to the linked section of the page. On clicking an internal link, the page gets scrolled automatically and displays the referred section on the screen.

Build an AI-First Career, Master the Complete Skillset

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program
NSDC Certified

AI Forward Deployed Engineer Program

Full-stack engineering, production AI and client-facing consulting

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program

Syntax

Target Attribute

The target attribute specifies where the linked page will open. By default, the linked document file opens in the same tab. However, you can change this by specifying different values for the target attribute.

The values of the target attribute are:

ValueDescription
_selfThis is the default value that opens the targeted link in the same tab.
_blankThe linked document opens in a new tab or window.
_parentThe targeted document will open in the parent frame.
_topThe linked document will open in the full body of the window.
Sharpen Your Fundamentals with Free Learning

Example

The following piece of code shows an HTML file that has internal links.

Code

Output

html-file-with-internal-link-output

How Scaler Transformed Careers in Different Fields

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Though the link states have default HTML link colors, the users can change the colors as per requirements. The default colors are blue for an unvisited link, purple for a visited hyperlink, and red for a link in an active state. However, the default colors can be altered using HTML and CSS.

Code

HTML

CSS

Output

changing-link-color-html-output.

Linking to Parts of Other Documents

Given below is a piece of code that targets a particular section of another document. The name of the id is appended at the end of the target link with a #. The hashtag (#) is known as the fragment identifier. After opening, the target document scrolls automatically till it reaches the mentioned section. Example - <a href="https://www.link.com/webpage#idname">

Code

Output In the following example, you can see the referred link opens and then automatically scrolls to the section whose id is 'syntax'.

link-to-other-documents-html-output

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Learn more

Conclusion

  • HTML internal link is linked within the same web page.
  • The value of href is a hashmark followed by the name of the id of the linked section.
  • The hashmark(#) is known as a fragment identifier.