html_links.asp@output=print
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HTML Links</title>
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />
<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</head>
<body>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
<h1>HTML Links</h1>
<a href="html_entities.asp"><img border="0" src="../images/btn_previous.gif" alt="Previous" width="100" height="20" /></a>
<a href="html_frames.asp"><img border="0" src="../images/btn_next.gif" alt="Next" width="100" height="20" /></a>
<hr />
<p class="intro">HTML uses a hyperlink to link to another document on the Web.</p>
<hr />
<h2>Examples</h2>
<p>
<a target="_blank" href="tryit.asp@filename=tryhtml_links">Create hyperlinks</a><br />
This example demonstrates how to create links in an HTML document.
</p>
<p><a target="_blank" href="tryit.asp@filename=tryhtml_imglink">An image as a link</a><br />
This example demonstrates how to use an image as a link.
</p>
<p>(You can find more examples at the bottom of this page)</p>
<hr />
<h2>The Anchor Tag and the Href Attribute</h2>
<p><b>HTML uses the <a> (anchor) tag to create a link to another document.</b></p>
<p>An anchor can point to any resource on the Web: an HTML page, an image, a sound file, a movie,
etc.</p>
<p>The syntax of creating an anchor: </p>
<table width="100%" class="ex" cellspacing="0" border="1">
<tr>
<td>
<pre><a href="url">Text to be displayed</a></pre>
</td>
</tr>
</table>
<p>
The <a> tag is used to create
an anchor to link from, the href attribute is used to address the document
to link to, and the words between the open and close of the anchor tag will be displayed as a hyperlink.</p>
<p>This anchor defines a link to W3Schools:</p>
<table width="100%" class="ex" cellspacing="0" border="1">
<tr>
<td>
<pre><a href="http://www.w3schools.com/">Visit W3Schools!</a></pre>
</td>
</tr>
</table>
<p>The line above will look like this in a browser:</p>
<p><a href="../default.htm">Visit W3Schools!</a></p>
<hr />
<h2>The Target Attribute</h2>
<p>With the target attribute, you can define <b> where</b> the linked document will be
opened.</p>
<p>The line below will open the document in a new browser window:</p>
<table width="100%" class="ex" cellspacing="0" border="1">
<tr>
<td>
<pre><a href="http://www.w3schools.com/"
target="_blank">Visit W3Schools!</a></pre>
</td>
</tr>
</table>
<br />
<hr />
<h2>The Anchor Tag and the Name Attribute</h2>
<p>The name attribute is used to create a named anchor. When using named anchors
we can create links that can jump directly into a specific section on a page, instead of
letting the user scroll around to find what he/she is looking for.</p>
<p>Below is the syntax of a named anchor:</p>
<table width="100%" class="ex" cellspacing="0" border="1">
<tr>
<td>
<pre><a name="label">Text to be displayed</a></pre>
</td>
</tr>
</table>
<p>The name attribute is used to create a named anchor. The name of the anchor
can be any text you care to use.</p>
<p>The line below defines a named anchor:</p>
<table width="100%" class="ex" cellspacing="0" border="1">
<tr>
<td>
<pre><a name="tips">Useful Tips Section</a></pre>
</td>
</tr>
</table>
<p>You should notice that a named anchor is not displayed in a special way.</p>
<p>To link directly to the "tips" section, add a # sign and the name of the anchor to the end of
a
URL, like this:</p>
<table width="100%" class="ex" cellspacing="0" border="1">
<tr>
<td>
<pre><a href="http://www.w3schools.com/html_links.asp#tips">
Jump to the Useful Tips Section</a></pre>
</td>
</tr>
</table>
<p>A hyperlink to the Useful Tips Section from WITHIN the file "html_links.asp"
will look like this: </p>
<table width="100%" class="ex" cellspacing="0" border="1">
<tr>
<td>
<pre><a href="#tips">Jump to the Useful Tips Section</a></pre>
</td>
</tr>
</table>
<br />
<hr />
<h2>Basic Notes - Useful Tips</h2>
<p>Always add a trailing slash to subfolder references. If you link like this: href="http://www.w3schools.com/html",
you will generate two HTTP requests to the server, because the server will add a slash
to the address and create a new request like this: href="http://www.w3schools.com/html/" </p>
<p>Named anchors are often used to create "table of contents" at the beginning
of a large document.
Each chapter within the document is given a named anchor, and links to each of these anchors are put at the top of the
document.</p>
<p>If a browser cannot find a named anchor that has been specified, it goes to the top of the
document. No error occurs. </p>
<hr />
<h2>More Examples</h2>
<p>
<a target="_blank" href="tryit.asp@filename=tryhtml_link_target">Open a link in a new browser
window</a><br />
This example demonstrates how to link to another page by opening a new
window, so that the visitor does not have to leave your Web site.
</p>
<p>
<a target="_blank" href="tryit.asp@filename=tryhtml_link_locations">Link to a location on the
same page</a><br />
This example demonstrates how to use a link to jump to another part of a document.
</p>
<p><a target="_blank" href="tryit.asp@filename=tryhtml_frame_getfree">Break out of a frame</a><br />
This example demonstrates how to break out of a frame, if your site is locked in a frame.
</p>
<p><a target="_blank" href="tryit.asp@filename=tryhtml_mailto">Create a mailto link</a><br />
This example demonstrates how to link to a mail message (will only work if
you have mail installed).</p>
<p><a target="_blank" href="tryit.asp@filename=tryhtml_mailto2">Create a mailto link 2</a><br />
This example demonstrates a more complicated mailto link.</p>
<hr />
<h2>Link Tags</h2>
<table class="ex" cellspacing="0" border="1" width="100%">
<tr>
<th width="30%" align="left">Tag</th>
<th align="left">Description</th>
</tr>
<tr>
<td><a href="../tags/tag_a.asp"><a></a></td>
<td>Defines an anchor</td>
</tr>
</table>
<br />
<hr />
<a href="html_entities.asp"><img border="0" src="../images/btn_previous.gif" width="100" height="20" alt="Previous" /></a>
<a href="html_frames.asp"><img border="0" src="../images/btn_next.gif" width="100" height="20" alt="Next" /></a>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -