Quantcast
Channel: Topliners : All Content - All Communities
Viewing all articles
Browse latest Browse all 2909

How to Add Links to Content within Your HTML Document - Named Anchors

$
0
0

This question comes up often: In my HTML emails (or landing pages), I want to create a link at the top (such as in a table of contents) that points to a section of content lower in the document. This is pretty easy to do. You simply use the name attribute for the anchor tag to create the bookmark and then you create your link at the top of the document where the href property is just a # sign and the name of the first anchor you created.

 

HTML Links - The name Attribute

  • The name attribute specifies the name of an anchor.
  • The name attribute is used to create a bookmark inside an HTML document.
  • Bookmarks are not displayed in any special way. They are invisible to the reader.


Here's How:

Create a named anchor just before the content section in your HTML document:

 

   <a name="tips">Useful Tips Section</a> 

 

Create a link to the "Useful Tips Section" inside the same document:

 

   <a href="#tips">Visit the Useful Tips Section</a> 

You can also link to this section within your document from another page. Here's how that is done:

 

Create a link to the "Useful Tips Section" from another page:

 

<a href="http://www.w3schools.com/html_links.htm#tips">Visit the Useful Tips Section</a>

 

Live Example:

 

Here's a live example that you can play with:

http://www.w3schools.com/html/tryit.asp?filename=tryhtml_link_locations


Viewing all articles
Browse latest Browse all 2909

Trending Articles