Files
freeCodeCamp/guide/english/html/attributes/href-attribute/index.md
Ayushman9454 eb78b09ff8 added another use (#26992)
* added another use

* Fixed formatting
2019-01-16 23:22:02 -05:00

28 lines
800 B
Markdown

---
title: Href Attribute
---
## Href Attribute
Href is short for "Hypertext Reference" and is an HTML attribute. The href attribute is mainly used for `<a>` tags to specify the URL for a webpage the link leads to (whether it be on a different section of the same page, or on a completely different webpage).
#### How to use
`<a href="URL"></a>`
#### Examples
```html
<a href="https://www.freecodecamp.org">This is an absolute URL</a>
<a href="index.html">This is a relative URL</a>
```
#### Another use
`<a href="#top">Go to top</a>`
#### Description
It will take you to that position in the page where `id="top"` is given.
#### More Information:
[W3Schools](https://www.w3schools.com/tags/att_href.asp)
[HTMLElementReference](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a)