• 目录

超链接 a 标签

阅读量: 193 编辑

超链接 a 标签

通过 a 标签可以在网页中打开其他的链接

一、超链接 a 的语法

主要用于打开其他网页,其中非常重要的属性是 href 属性,对应的值是其他网页的链接

  • 如果是其他网站的链接,要以 http:// 开头

  • 如果不想跳转到其他链接,写成 javascript:void(0)

  • 打开同一个项目中的链接 直接写相对地址就行了

属性 target="_blank",打开新的窗口实现链接跳转

二、代码实战

代码的详细解读,可以参考视频教程。

新建 html 文件 08-a.html,编写下方程序,运行看看效果吧

<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>超链接a标签</title>
    </head>
    
    <body>
        <a href="http://www.xxxx.com">xxx网站</a>
        <br/>
        <a href="javascript:void(0)">不跳转</a>
        <br/>
        <a href="./07-ul.html">UL标签</a>
        <br/>
        <a href="./07-ul.html" target="_balnk">UL标签,新窗口</a>
    </body>
    
</html>


  • 目录