freeCodeCamp/guide/chinese/html/attributes/href/index.md

56 lines
1.3 KiB
Markdown
Raw Normal View History

---
title: Href
localeTitle: HREF
---
## HREF
超文本引用HREF是一种HTML属性可用于指定链接目标或统一资源定位符URL。最常见的是您会看到HREF属性与锚标签`<a>`配对。
HREF属性根据使用它的元素获取链接的确切含义。例如当与`<a>`标签一起使用时它将表示对象的位置表示为URL。将HREF属性与`<image>`标记一起使用时HREF属性引用要呈现的图像的URL。
### 例子:
链接到Google的主页
\- >文本“访问Google的主页就像链接到主页一样
```html
<a href="https://www.google.com">Visit Google's Homepage</a>
```
图像作为链接:
\- > Google徽标指的是Google的主页
```html
<a href="https://www.google.com">
<img border="0" alt="Google" src="https://www.google.com/logos/doodles/2015/googles-new-logo-5078286822539264.3-hp2x.gif" width="100" height="100">
```
使用HREF的标签
```html
<a>
<area>
<base>
<cursor>
<discard>
<feImage>
<hatch>
<image>
<link>
<mesh>
<meshgradient>
<mpath>
<pattern>
<script>
<textPath>
<use>
```
#### 更多信息:
[无论如何WTF是一个href](https://tomayko.com/blog/2008/wtf-is-an-href-anyway) [MDN](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/href)