...

View Full Version : Firefox anchor issue



johnnyblotter
01-18-2008, 11:42 PM
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

Majoracle
01-19-2008, 03:41 AM
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".

rmedek
01-19-2008, 06:21 AM
…or, to put all possible combos together:


<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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum