3

When I validate this page with the w3c validator, I am told that "the name attribute is obsolete," however, I cannot find an alternative. Every article I can find about linking within a page still seems to specify using the name attribute. And the method that is mentioned on the validator (linking to an "id") doesn't seem to work for me.

Anyone know the correct alternative, or how to correctly link to an id?

Also, I'd like to be able to link to a specific point just above where the anchor points currently are...is there any way to be more specific about where the page scrolls/jumps to?

http://firewalkcreative.com/2012/2012.html

Daniel
  • 23,129
  • 12
  • 109
  • 154
  • 1
    This has been answered here, id tag should work: http://stackoverflow.com/questions/3036322/html5-how-to-skip-navigation-when-name-attribute-is-obsolete – SwiftD Aug 09 '12 at 17:31

3 Answers3

4

You can skip to any element with specified identifier like that:

<div id="navigation"></div>

<div id="content"></div>

<div id="footer"></div>

<a href="#navigation">Skip to navigation</a>
Edward Ruchevits
  • 6,411
  • 12
  • 51
  • 86
3

you can use a class name or an id:

<a id="top"></a>

<a class="top"></a>

or you can assign multiple class to make it more specific

<a class="link top"></a>

or with html5 you can do this:

<a data-name="top" ></a>
Ibu
  • 42,752
  • 13
  • 76
  • 103
  • Wat has that to do with internal linking? you can not internal linking with class names or attributes – Mark Aug 09 '12 at 17:35
  • So after trying all of these, and none of them working, I realized that they do work, and you are right, and the problem is in the smoothpack javascript code I'm using to do the scrolling...which I didn't write. When I take that away, linking to an id works. Any ideas on a scrolling script that works with id's? – Elliott Samuel Lemberger Aug 09 '12 at 19:01
2

in the old days, speek html 4, you could to internal links like:

<a href="#bottom">link</a>

and the target would be

<a name="bottom"></a>

Now this days we do it like that:

<a href="#bottom">link</a>

target:

<foo id="bottom"></foo>

You see i use foo, because it can be whatever element you like

Mark
  • 6,762
  • 1
  • 33
  • 50
  • The [HTML 4.0.1 spec](http://www.w3.org/TR/html401/struct/links.html#h-12.2.3) says: `The id attribute may be used to create an anchor at the start tag of any element (including the A element).` – Torsten Walter Aug 09 '12 at 17:35