Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

a name vs. span id?

Question posted by: yawnmoth (Guest) on June 27th, 2008 07:16 PM
Is there any reason to use <a name="..."over <span id="..."(or
div / img / whatever)?

Going to page.html#... seems to work the same for me on IE7 and FF2,
regardless. Maybe the id="..." stuff doesn't work on older browsers?
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
Jim Moe's Avatar
Jim Moe
Guest
n/a Posts
June 27th, 2008
07:16 PM
#2

Re: a name vs. span id?
On 05/26/08 11:27 am, yawnmoth wrote:
Quote:
Originally Posted by
Is there any reason to use <a name="..."over <span id="..."(or
div / img / whatever)?
>

It depends. What is the context of the question?
Quote:
Originally Posted by
Going to page.html#... seems to work the same for me on IE7 and FF2,
regardless. Maybe the id="..." stuff doesn't work on older browsers?


True.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)

yawnmoth's Avatar
yawnmoth
Guest
n/a Posts
June 27th, 2008
07:16 PM
#3

Re: a name vs. span id?
On May 26, 1:29 pm, Jim Moe <jmm-list.AXSPA...@sohnen-moe.comwrote:
Quote:
Originally Posted by
On 05/26/08 11:27 am, yawnmoth wrote:Is there any reason to use <a name="..."over <span id="..."(or
Quote:
Originally Posted by
div / img / whatever)?

>
It depends. What is the context of the question?


None, really. I was viewing the HTML source of some webpage, looking
for an anchor name I could link to and didn't find one. I did,
however, find an id, and, just for kicks and giggles, decided to use
that after the # and it worked, to my surprise.

All the webpages / webapps I've worked, thus far, on have used anchor
name. I don't plan on updating those applications but I might do
future ones with id's, instead.

I'm not really sure how many contexts there could be for a question
such as this?

Adrienne Boswell's Avatar
Adrienne Boswell
Guest
n/a Posts
June 27th, 2008
07:16 PM
#4

Re: a name vs. span id?
Gazing into my crystal ball I observed yawnmoth <terra1024@yahoo.com>
writing in news:036ac27a-fae2-482e-8870-3ac739244e26@
8g2000hse.googlegroups.com:
Quote:
Originally Posted by
Is there any reason to use <a name="..."over <span id="..."(or
div / img / whatever)?
>
Going to page.html#... seems to work the same for me on IE7 and FF2,
regardless. Maybe the id="..." stuff doesn't work on older browsers?


The id attribute can be used for all elements except BASE, HEAD, HTML,
META, SCRIPT, STYLE, TITLE.

That means you could do:
<h1>Page Title</h1>
<p>Bla...</p>
<h2 id="heading2">Second Level Heading</h2>
<p>Bla...</p>

The A element is inline, and therefore has to be wrapped in a block
element, so more markup, eg:
<h2><a name="heading2">Second Level Heading</a><h2>

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share


Michael Fesser's Avatar
Michael Fesser
Guest
n/a Posts
June 27th, 2008
07:16 PM
#5

Re: a name vs. span id?
..oO(yawnmoth)
Quote:
Originally Posted by
>On May 26, 1:29 pm, Jim Moe <jmm-list.AXSPA...@sohnen-moe.comwrote:
Quote:
Originally Posted by
>On 05/26/08 11:27 am, yawnmoth wrote:Is there any reason to use <a name="..."over <span id="..."(or
Quote:
Originally Posted by
div / img / whatever)?

>>
> It depends. What is the context of the question?

>
>None, really. I was viewing the HTML source of some webpage, looking
>for an anchor name I could link to and didn't find one. I did,
>however, find an id, and, just for kicks and giggles, decided to use
>that after the # and it worked, to my surprise.


It's a defined behaviour and the recommended way for named anchors, even
though it will not work in really old browsers (NN4 and the like). If
compatibility with the last century is an issue, use 'a' elements with
'name' attributes, otherwise use IDs on any elements you like.

Micha

Roy A.'s Avatar
Roy A.
Guest
n/a Posts
June 27th, 2008
07:16 PM
#6

Re: a name vs. span id?
On 26 Mai, 20:27, yawnmoth <terra1...@yahoo.comwrote:
Quote:
Originally Posted by
Is there any reason to use <a name="..."over <span id="..."(or
div / img / whatever)?


The a element is a semantic element, the span element is an undefined
element used for grouping text-elements.
Quote:
Originally Posted by
Going to page.html#... seems to work the same for me on IE7 and FF2,
regardless. *Maybe the id="..." stuff doesn't work on older browsers?


This stuff works in all current browsers. Use the id attribute on
current elements,
don't add additonal elements just to have some fragment to refere to.
But the a-
element is there, and there is no places in the specification that say
that you can't
us an id-attibute on an a element. If I wanted an keyword to the left,
in front of some of may
paragraph, why shoud I use a span-element, if I could use an a-elment?
Nothing say I can't.


 
Not the answer you were looking for? Post your question . . .
183,944 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors