named anchor

Download Report

Transcript named anchor

Anchor Element
• You have seen that href anchors create links.
• The alternative it so use the name attribute.
•You can’t use both the name and href attributes in the
same a element.
Using the name attribute in the anchor element creates
an named anchor or invisible anchor in the Web page.
<a name="charley”></a>
• Nothing visible results in the Web page.
• An invisible anchor marks a location in the Web
page.
• If a link points an invisible anchor, clicking the link
will cause the invisible anchor to go to the top of the
browser window.
• An href anchor is used to link to a named anchor.
<a href="#charley”>go to charley</a>
• Clicking this link brings the anchor named "charley"
to the top of the browser window. That is, the location
in the Web page marked by the invisible anchor is
moved to the top of the window.
• What you link to (#charley) is called a URL
fragment or fragment identifier.
An online book with named anchors for each chapter
and links which bring those chapters to the top of the
window.
You can also put content in an invisible anchor.
<a name="charley”>take me to top</a>
The anchor is still invisible. That is no formatting is
applied to the text in the anchor.
But for some very subtle differences, that will work
the same as.
<a name="charley”></a>
take me to top
Linking to named anchors in other pages.
From anywhere (absolute URL):
<a href="http://www.uweb.edu/
~jones/sports/football.html#middle">
go to middle of football page
</a>
From within the same Web site (relativeURL):
<a href="sports/football.html#middle">
go to middle of football page
</a>