posts - 262,  comments - 221,  trackbacks - 0
资料来源:www.w3cschools.com

一、HTML中的href属性:

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.

<a href="http://www.w3schools.com/">Visit W3Schools!</a>

备注:
1). 像href=”www.163.com“的写法是错误的,必须改为href="http://www.163.com"
2). 如果href属性的值以/开头,则表示相对于服务器的根目录,如果没有则表示相对于当前页面

二、HTML中的target属性:

With the target attribute, you can define where the linked document will be opened.

<a href="http://www.w3schools.com/" target="_blank">Visit W3Schools!</a>

三、HTML中的name属性:

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.

You should notice that a named anchor is not displayed in a special way.To link directly to the "tips" section, add a # sign and the name of the anchor to the end of a URL.

<a name="tips">Useful Tips Section</a>

备注:
一个被锚标记标注的文本并不会有什么特别的显示,要想使用锚标记进行页间跳转,只需要在URL的末尾加上一个#号和锚标记的名称就可以了。如果是进行页内跳转则简单地使用#号加锚标记的名称就可以了(连URL都不用了)。

<a href="http://www.w3schools.com/html_links.asp#tips">
    Jump to the Useful Tips Section
</a>

<a href="#tips">Jump to the Useful Tips Section</a>

四、关于超链接的一些注意点:

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/"

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.

If a browser cannot find a named anchor that has been specified, it goes to the top of the document. No error occurs.



-------------------------------------------------------------
生活就像打牌,不是要抓一手好牌,而是要尽力打好一手烂牌。
posted on 2008-06-04 10:33 Paul Lin 阅读(344) 评论(0)  编辑  收藏 所属分类: Web基础

只有注册用户登录后才能发表评论。


网站导航:
 
<2008年6月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

常用链接

留言簿(19)

随笔分类

随笔档案

BlogJava热点博客

好友博客

搜索

  •  

最新评论

阅读排行榜

评论排行榜