Table of Contents
HTML href
实例解析
效果展示
HTML target
HTML name
Home Web Front-end HTML Tutorial LN :跟着W3School学HTML 011_html/css_WEB-ITnose

LN :跟着W3School学HTML 011_html/css_WEB-ITnose

Jun 24, 2016 am 11:15 AM

LN :跟着W3School学HTML 011

内容参考自W3School

HTML 教程

有两种使用 标签的方式:

  1. 通过使用 href 属性 - 创建指向另一个文档的链接
  2. 通过使用 name 属性 - 创建文档内的书签

HTML href

  • "链接文本" 不必一定是文本。图片或其他 HTML 元素都可以成为链接
  • 实例解析

    <a href="http://www.cnblogs.com/renleimlj/">Visit my blog!</a>
    Copy after login

    效果展示

    Visit my blog!

    HTML target

  • 使用 Target 属性,你可以定义被链接的文档在何处显示
  • 实例解析

    <html><body><a href="http://www.cnblogs.com/renleimlj/" target="_blank">Visit my blog!</a><p>如果把链接的 target 属性设置为 "_blank",该链接会在新窗口中打开。</p></body></html>
    Copy after login

    效果展示

    Visit my blog!

    如果把链接的 target 属性设置为 "_blank",该链接会在新窗口中打开。

    HTML name

  • name 属性规定锚(anchor)的名称,可用来创建书签
  • 书签不会以任何特殊方式显示,它对读者是不可见的
  • 锚(显示在页面上的文本)
  • 锚的名称可以是任何你喜欢的名字
  • 可以使用 id 属性来替代 name 属性,命名锚同样有效
  • 实例解析

    首先,我们在 HTML 文档中对锚进行命名(创建一个书签):

    <a name="tips">基本的注意事项 - 有用的提示</a>
    Copy after login

    然后,我们在同一个文档中创建指向该锚的链接:

    <a href="#tips">有用的提示</a>
    Copy after login

    效果展示

    基本的注意事项 - 有用的提示
    有用的提示

    基本的注意事项 - 有用的提示:
    注释:请始终将正斜杠添加到子文件夹。假如这样书写链接:href="",就会向服务器产生两次 HTTP 请求。这是因为服务器会添加正斜杠到这个地址,然后创建一个新的请求,就像这样:"。
    提示:命名锚经常用于在大型文档开始位置上创建目录。可以为每个章节赋予一个命名锚,然后把链接到这些锚的链接放到文档的上部。如果您经常访问百度百科,您会发现其中几乎每个词条都采用这样的导航方式。
    提示:假如浏览器找不到已定义的命名锚,那么就会定位到文档的顶端。不会有错误发生。

    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

    Swap faces in any video effortlessly with our completely free AI face swap tool!

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

    HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

    What is the purpose of the <progress> element? What is the purpose of the <progress> element? Mar 21, 2025 pm 12:34 PM

    The article discusses the HTML &lt;progress&gt; element, its purpose, styling, and differences from the &lt;meter&gt; element. The main focus is on using &lt;progress&gt; for task completion and &lt;meter&gt; for stati

    The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

    HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

    What is the purpose of the <datalist> element? What is the purpose of the <datalist> element? Mar 21, 2025 pm 12:33 PM

    The article discusses the HTML &lt;datalist&gt; element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

    What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

    The article discusses the HTML &lt;meter&gt; element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates &lt;meter&gt; from &lt;progress&gt; and ex

    What is an example of a starting tag in HTML? What is an example of a starting tag in HTML? Apr 06, 2025 am 12:04 AM

    AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

    Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

    WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

    Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Apr 04, 2025 pm 11:54 PM

    GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

    See all articles