Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2006
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Firefox anchor issue

    Okay, I know the usual way to create an anchor is by using the a element, as in :

    <a name="name" href="www.dsfsdf.com">The Anchor</a>

    However I want to use an <h2> element as an anchor as it sits in a more convenient place. I'm reading in my CSS book here that you can use id values of elements as anchors. This is working fine in IE6 but doesn't seem to work in Firefox. Anyone run into this before?

    thanks

    Jon

  • #2
    Regular Coder
    Join Date
    Nov 2006
    Posts
    247
    Thanks
    13
    Thanked 26 Times in 24 Posts
    If you're referring to element linking, it's quite easy..

    Anchor: <a href="#section1">Go to Section 1</a>
    Element: <h2 id="section1">Section 1</h2>

    Clicking "Go to Section 1" on the page would make the browser scroll to the beginning of the element named "section1". I hope that's what you were referring to. If not, this is probably what your CSS book was referring to when it said "use id values of elements as anchors".

    The only other thing I can think of is that you want to actually make a click able H2. The only way this would be possible is with JavaScript and "onclick".
    Last edited by Majoracle; 01-19-2008 at 04:38 AM.

  • #3
    Senior Coder
    Join Date
    Nov 2003
    Location
    Minneapolis, MN
    Posts
    2,879
    Thanks
    2
    Thanked 65 Times in 56 Posts
    …or, to put all possible combos together:

    Code:
    <h1>Example</h1>
    <p><a href="#excerpt">Jump right to the excerpts</a></p>
    
    <p>some text that's in the way</p>
    
    <h2 id="excerpt"><a href="http://example.com/article1.html">Article One</a></h2>
    <p>This is the article excerpt, you can also view the whole thing if you want.</p>
    <p><a href="http://example.com/article1.html">Read the whole thing</a></p>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •