Difference between revisions of "A (HTML element)"
Karl Jones (Talk | contribs) (→Full-qualified URL) |
Karl Jones (Talk | contribs) (→Full-qualified URL) |
||
Line 5: | Line 5: | ||
=== Full-qualified URL === | === Full-qualified URL === | ||
− | Use a fully-qualified URL when linking to another website | + | Use a fully-qualified URL when linking to another website: |
<nowiki><a href="http://wikipedia.org">Wikipedia</a></nowiki> | <nowiki><a href="http://wikipedia.org">Wikipedia</a></nowiki> | ||
+ | |||
+ | === Document-relative URLs === | ||
+ | |||
+ | Document-relative URLs are convenient and widely used in web design. | ||
+ | |||
+ | The simplest case is a link to a destination web page in the same folder: | ||
+ | |||
+ | <nowiki><a href="destination.html">Destination page</a></nowiki> | ||
+ | |||
+ | In the example below, the destination page is in a subfolder named ''sub'': | ||
+ | |||
+ | <nowiki><a href="sub/destination.html">Destination page</a></nowiki> | ||
+ | |||
+ | In the example below, the destination page is one step closer to the [[web root]]: | ||
+ | |||
+ | <nowiki><a href="../destination.html">Destination page</a></nowiki> | ||
+ | |||
+ | The example below demonstrates one step closer to the web root, then in a subfolder named ''sub2'': | ||
+ | |||
+ | <nowiki><a href="../sub2/destination.html">Destination page</a></nowiki> | ||
=== Link to a Microsoft Word document === | === Link to a Microsoft Word document === |
Revision as of 19:15, 20 April 2016
In HTML, a (for "anchor") represents a hyperlink.
Contents
Examples
Full-qualified URL
Use a fully-qualified URL when linking to another website:
<a href="http://wikipedia.org">Wikipedia</a>
Document-relative URLs
Document-relative URLs are convenient and widely used in web design.
The simplest case is a link to a destination web page in the same folder:
<a href="destination.html">Destination page</a>
In the example below, the destination page is in a subfolder named sub:
<a href="sub/destination.html">Destination page</a>
In the example below, the destination page is one step closer to the web root:
<a href="../destination.html">Destination page</a>
The example below demonstrates one step closer to the web root, then in a subfolder named sub2:
<a href="../sub2/destination.html">Destination page</a>
Link to a Microsoft Word document
Link to a Microsoft Word document by setting the link's href attribute (HTML) to the name of the Word document:
<a href="filename.docx">Download Word document</a>
In this example, the Word document is in the same folder as the web page containing the link.
If the Word document is located elsewhere, modify the href attribute to specify the path to the document:
<a href="../documents/filename.docx">Download Word document</a>
See also
External links
- a element @ W3.org
- Links @ W3.org
- Fragment identifiers @ W3.org
- HTML a tag @ W3schools.com
- HTML a href attribute @ W3schools.com
- Hyperlink @ Wikipedia
- Inline linking @ Wikipedia