📜  herf - Html (1)

📅  最后修改于: 2023-12-03 15:15:30.716000             🧑  作者: Mango

HREF - HTML

Introduction

HREF in HTML stands for Hypertext Reference which refers to a hyperlink that is embedded in a web page. It specifies the URL of the resource being linked and provides a clickable link to the user.

A HREF attribute can be added to various HTML elements like text, images, buttons, and more to create a clickable link to another web page, image, video, or document.

Syntax

The syntax for HREF attribute is as follows:

<a href="URL">Link text</a>

Here, href is the attribute name, and URL is the web address of the target link. The Link text is the clickable text that appears on the web page.

Examples
Linking to another web page
<a href="https://www.google.com">Go to Google</a>
Linking to an image
<a href="https://www.example.com/images/sample.jpg">
   <img src="https://www.example.com/images/sample_thumb.jpg" alt="Sample image">
</a>
Linking to an email address
<a href="mailto:info@example.com">Contact Us</a>
Linking to a specific section of a web page
<a href="#section2">Go to Section 2</a>
...
<h2 id="section2">Section 2</h2>
Conclusion

HREF in HTML is a powerful tool to add links to web pages, images, documents, and more. With its simple syntax and various attributes, it is easy to create clickable links to other resources.