Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Member fortm's Avatar
    Join Date
    Jul 2011
    Posts
    30
    Member #
    28679
    I am looking to create a named link in HTML page so that when user clicks on first link, then top line of page is -
    Chapter 4 starts. Here is chapter 4
    And if user clicks on second link, topmost line is -
    Chapter 5 starts. Here is chapter 5

    Code:
    <html>
    <body>
    
    Click <a href="#chapter4">here</a> to read chapter 4.
    Click <a href="#chapter5">here</a> to read chapter 5.
    
    <BR>
    <a name="chapter4">Chapter 4 starts. Here is chapter 4</a>
    <BR>
    <a name="chapter5">Chapter 5 starts.Here is chapter 5</a>
    </body>
    </html>
    This code takes to those links but the new link is not showing as topmost line of page.
    Can you please help in correcting this HTML ?

  2.  

  3. #2
    Senior Member Webzarus's Avatar
    Join Date
    May 2011
    Location
    South Carolina Coast
    Posts
    3,322
    Member #
    27709
    Liked
    770 times
    Anchors can't be links.... anchors are just a point of reference in the document or another document, where you want the page to start displaying when a user clicks a link that references an anchor.

    for what you appear to be doing, you will need to create a separate link and anchor.

    Anchors are not displayed so you can actually place them several line above the actual text you want to display, so the text is not at the very top of the screen.

    BTW... anchors only work if the anchor is not already visible on the page that you are viewing.

  4. #3
    Junior Member Angie's Avatar
    Join Date
    Sep 2011
    Location
    Portland, OR
    Posts
    10
    Member #
    29211
    Liked
    4 times
    Here's what your code should look like:
    HTML Code:
    <html>
    <body>
    
    Click <a href="#chapter4">here</a> to read chapter 4.
    Click <a href="#chapter5">here</a> to read chapter 5.
    
    <br />
    <span id="chapter4">Chapter 4 starts. Here is chapter 4</span>
    <br />
    <span id="chapter5">Chapter 5 starts.Here is chapter 5</span>
    </body>
    </html>
    When you have "#someanchorname", it's pointing to an ID attribute, not a name attribute. Additionally I changed your "<a>" to "<span>" so that the line "Chapter X starts..." isn't a link itself since it (probably) doesn't need to point to anything.

  5. #4
    Member fortm's Avatar
    Join Date
    Jul 2011
    Posts
    30
    Member #
    28679
    thanks , i achieved this by adding lot of line breaks after Chapter 5 line.

  6. #5
    Junior Member
    Join Date
    Sep 2011
    Location
    Northern Virginia
    Posts
    6
    Member #
    29322
    Quote Originally Posted by Angie, post: 218902
    Here's what your code should look like:
    HTML Code:
    <html>
    <body>
    
    Click <a href="#chapter4">here</a> to read chapter 4.
    Click <a href="#chapter5">here</a> to read chapter 5.
    
    <br />
    <span id="chapter4">Chapter 4 starts. Here is chapter 4</span>
    <br />
    <span id="chapter5">Chapter 5 starts.Here is chapter 5</span>
    </body>
    </html>
    When you have "#someanchorname", it's pointing to an ID attribute, not a name attribute. Additionally I changed your "<a>" to "<span>" so that the line "Chapter X starts..." isn't a link itself since it (probably) doesn't need to point to anything.

  7. #6
    Junior Member
    Join Date
    Sep 2011
    Location
    Northern Virginia
    Posts
    6
    Member #
    29322
    Yes it is a right coding.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:53 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com