We are independent & ad-supported. We may earn a commission for purchases made through our links.
Advertiser Disclosure
Our website is an independent, advertising-supported platform. We provide our content free of charge to our readers, and to keep it that way, we rely on revenue generated through advertisements and affiliate partnerships. This means that when you click on certain links on our site and make a purchase, we may earn a commission. Learn more.
How We Make Money
We sustain our operations through affiliate commissions and advertising. If you click on an affiliate link and make a purchase, we may receive a commission from the merchant at no additional cost to you. We also display advertisements on our website, which help generate revenue to support our work and keep our content free for readers. Our editorial team operates independently of our advertising and affiliate partnerships to ensure that our content remains unbiased and focused on providing you with the best information and recommendations based on thorough research and honest evaluations. To remain transparent, we’ve provided a list of our current affiliate partners here.
Software

Our Promise to you

Founded in 2002, our company has been a trusted resource for readers seeking informative and engaging content. Our dedication to quality remains unwavering—and will never change. We follow a strict editorial policy, ensuring that our content is authored by highly qualified professionals and edited by subject matter experts. This guarantees that everything we publish is objective, accurate, and trustworthy.

Over the years, we've refined our approach to cover a wide range of topics, providing readers with reliable and practical advice to enhance their knowledge and skills. That's why millions of readers turn to us each year. Join us in celebrating the joy of learning, guided by standards you can trust.

What Are HTML Anchors?

By Eugene P.
Updated: May 16, 2024
Views: 29,201
References
Share

Since nearly the start of the HyperText Markup Language (HTML) as used online, HTML anchors have remained one of the core interactive elements used in nearly all web pages. HTML anchors are a type of tag represented by the letter "A" that allows a user to click on an element and either be taken to a universal resource location (URL) such as another web page or to a different section within the same HTML document. It is more common to refer to HTML anchors as links or hyperlinks. Similar to many other HTML tags, anchors are able to be customized with both standard HTML formatting properties and cascading style sheet (CSS) extensions.

Within a web page, HTML anchors are used to move a user from one page to another, or to other marked locations within the same page. The anchor is represented by the letter "A" at the start of the tag. When moving between web pages, the address of the destination URL is assigned to the hypertext reference (href) property, although this also can be an image, a program or nearly any type of content. The default behavior of an anchor is to open the new URL in the same browser window, replacing the current content, although this behavior can be changed to open URLs in new windows or in targeted frames on a page.

The second use for HTML anchors is either to define or move to sections of the HTML document being viewed. By assigning a name to the anchor tag through the name property, an anchor is created in the document that can be referenced elsewhere. Just like moving to another web page, the anchor tag can be used to move to an anchor on the same page once it is defined, allowing for a table of contents or indexes to be created.

When using HTML anchors, the tag itself has no visual representation, but instead needs to enclose whatever visual elements will be used to represent it. The anchor tag can wrap around text, images or entire formatted blocks. By default, visual HTML elements that are surrounded by anchor tags are underlined and colored differently, depending on whether the link was visited by the user. Anchor text also changes color when a mouse hovers over it, although again this can be changed.

The use of HTML anchors to define locations within a single document has been depreciated and should not be used except to maintain legacy code. Instead, anchor locations within a document should be defined by assigning an identification (ID) through CSS to block level tags, such as headings. The anchor tag can, however, still be used to jump to these locations though a link.

Share
EasyTechJunkie is dedicated to providing accurate and trustworthy information. We carefully select reputable sources and employ a rigorous fact-checking process to maintain the highest standards. To learn more about our commitment to accuracy, read our editorial process.
Link to Sources
Discussion Comments
Share
https://www.easytechjunkie.com/what-are-html-anchors.htm
Copy this link
EasyTechJunkie, in your inbox

Our latest articles, guides, and more, delivered daily.

EasyTechJunkie, in your inbox

Our latest articles, guides, and more, delivered daily.