Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
HTML element
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====Anchor==== {{for|anchors on Wikipedia|WP:ANCHOR DEF|selfref=true}} {{glossary}} {{term|term=a |content= {{XMLElement|a|Anchor}} }} {{defn|1= <p>An anchor element is called an anchor because web designers can use it to "anchor" a URL to some text on a web page. When users view the web page in a browser, they can click the text to activate the link and visit the page whose URL is in the link.<ref>{{cite book |last1= Tittel |first1= Ed |last2= Burmeister |first2= Mary C. |date= 2005 |title= HTML 4 for dummies |edition= 5th |publisher= Wiley |location= Hoboken, New Jersey |isbn= 978-0-7645-8917-1 |page= 96 |url= https://archive.org/details/html4fordummies00titt_2/page/96/ |url-access= registration |access-date= 7 August 2022}}</ref></p> <p>In HTML, an "anchor" can be either the {{em|origin}} (the [[anchor text]]) or the {{em|target}} (destination) end of a [[hyperlink]]. As an origin, setting the attribute <code>href</code>,<ref>{{cite web|url=http://www.w3.org/Provider/ServerWriter.html|title=ServerWriter -- /Provider|website=W3C}}</ref> creates a hyperlink; it can point to either another part of the document or another resource (e.g. a webpage) using an external [[Uniform Resource Locator|URL]]. As a target, setting the <code>name</code> or <code>id</code> [[HTML attributes]], allows the element to be linked from a [[Uniform Resource Locator]] (URL) via a [[fragment identifier]]. The two forms, origin and anchor, can be used concurrently.</p> In HTML5, any element can now be made into a target by using the <code>id</code> attribute,<ref>{{cite web|url=http://www.w3.org/tr/html5/index.html#attributes-1|title=HTML 5.2|website=W3C}}</ref> so using {{code|lang=html|code=<a name="foo">...</a>}} is not necessary, although this way of adding anchors continues to work.</p> <p>To illustrate: the header of a table of contents section on <samp>example.com</samp>'s homepage could be turned into a target by writing: {{code|lang=html|code=<h2><a name="contents">Table of contents</a></h2>}}.</p> <p>Continuing with this example, now that the section has been marked up as a target, it can be referred to from external sites with a link like: {{code|lang=html|code=<a href="http://example.com#contents">see contents</a>}};</p> <p>or with a link on the same page like: {{code|lang=html|code=<a href="#contents">contents, above</a>}}.</p> <p>The attribute <code>title</code> may be set to give brief information about the link: {{code|lang=html|code=<a href="URL" title="additional information">link text</a>}}.</p> <p>In most graphical browsers, when the cursor hovers over a link, the cursor changes into a hand with an extended index finger and the <code>title</code> value is displayed in a [[tooltip]] or in some other manner. Some browsers render [[Alt attribute|alt text]] the same way, although this is not what the specification calls for.</p> }} {{defn|<code>A</code> existed in ''[[#HTMLTAGS|HTML Tags]]'', and was '''standardized''' in [[#HTML20|HTML 2.0]];}} {{glossary end}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)