Initially i thought that linking to anchor element can possible with name attribute of anchor element like this....
<a href="#targetlocation">......</a>
...........................................
...........................................
<a name="targetlocation">........................</a>
but i was wrong we can do in-page navigation with id attributes as well like this
We can put an
id
attribute on an any element like <a>
element, to make it into a page anchor,<div> element,heading element and so on. You then reference that ID in the href attribute of another link to link to it. For example:
<h2><a id="sec1">Section #1</a></h2>
Could be linked to by
<a href="#sec1">Section One</a>
But most browsers you'll want to support these days allow you to write a shortcut for this, and put the ID directly on the element you want to link to, for example:
<h2 id="sec1">Section #1</h2>
Till this knowledge it is ok 4 me but I surprised while working on a task that taget linking using "name attribute" not works for Chrome.So I used "id" attribute to resolve this problem and my problem had solved out......but still "picture abhi baki thi".........Id attribute was not working on Explorer....However any of the two ways works fine for Firefox.
From this observation, I had to use both method so that it could work fine in all
browsers like this.....
<a href="#targetlink">............................</a>
...............................
...............................
.......................
<div id="targetlink">.................</div>
<div reason="Internet explorer bug fix"><a name="targetlink"> </a></div> //reason attribute is given to give information for developers why this extra tag is there however we can give any xyz name other than reason.
...............................
Conclusion :
The
name
attribute has been deprecated in the XHTML 1.0 spec.so better to use "id" attribute
So, this would be a better option, as it would work for HTML 4.01, XHTML 1.0 and HTML 5.
.
No comments:
Post a Comment