HTML href is abbreviated as hypertext reference. This is the attribute that is available inside the anchor () tag. This href is used for website URLs like www.google.com, www.gmail.com, www.facebook.com etc.
Real-time Example: Day to day life, we have accessed so many websites. Have you ever think about how would we access this website url? Because of the href tag, we can access any website URLs. We simply required a website within this double quotes (href=”website”) of the href attribute.
How Does href Attribute Work in HTML?
HTML href attribute works based on which href tag we are using. All available href tags purpose is the same for accessing web URLs, but there is a slight difference.
There are 4 tags that allows the href attribute within it. They are:
1. : This tag is used for specifying the URL of the page where the link has to go within the href attribute.
Syntax:
<a href="URL%20link"></a>
2. : This tag is used for specifying the URL of the page where the link has to go within the href attribute.
Syntax:
<area href="URL%20link">
3.
Syntax:
<base href="Base%20URL%20link">
4. : This tag is used for specifying external file location like styles.css, javascript.js etc. within href attribute.
Syntax:
<link href="external%20link">
Examples to Implement href tag in HTML
Below are the different examples:
Example #1 – tag with href Attribute
Code:
<title>href attribute</title> <!--CSS code--> <style> p { color: green; border: 2px solid brown; font-size: 22px; } h1 { color: blue; text-align: center; } </style> <h1>The <a> tag with href attribute introduction</a> </h1> <p>HTML href is abbreviated as hypertext reference. This is the attribute which is available inside the anchor (<a>) tag. This href is used for website URLs like www.google.com, www.gmail.com, www.facebook.com etc.</a></p> <p>Real time Example: Day to day life we have accessed so many websites. Have you ever think about how would we access this website URLs? Because of href tag we can access any website URLs. We simply required website within this double quotes (href="website") of href attribute. </p> <h1>The <a> tag with href attribute URLs</a> </h1>
Output:
Example #2 – tag with href Attribute
Code:
<title>href attribute</title> <!--CSS code--> <style> p { color: fuchsia; border: 2px solid orange; font-size: 22px; } h1 { color: red; text-align: center; } </style> <h1>The <a> tag with href attribute introduction</a> </h1> <p>HTML href is abbreviated as hypertext reference. This is the attribute which is available inside the anchor (<a>) tag. This href is used for website URLs like www.google.com, www.gmail.com, www.facebook.com etc.</a></p> <p>Real time Example: Day to day life we have accessed so many websites. Have you ever think about how would we access this website URLs? Because of href tag we can access any website URLs. We simply required website within this double quotes (href="website") of href attribute. </p> <h1 id="The-area-tag-with-href-attribute-URLs-Example">The <area> tag with href attribute URLs Example</h1> <img src="/static/imghwm/default1.png" data-src="planets.gif" class="lazy" style="max-width:90%" style="max-width:90%" alt="href tag in HTML" usemap="#educba"> <map name="educba"> <!--Click on this coordinate gives you that images--> <area shape="rect" coords="0,0,81,125" href="sun.htm"> <area shape="circle" coords="91,59,4" href="mercur.htm"> <area shape="circle" coords="125,59,9" href="venus.htm"> </map>
Output:
After Click
Example #3 – tag with href Attribute
Code:
<title>href attribute</title> <!--From this path image is loaded--> <base href="https://www.w3schools.com/images/"> <!--CSS code--> <style> p { color: navy; border: 2px solid blue; font-size: 22px; } h1 { color: fuchsia; text-align: center; } </style> <h1>The <a> tag with href attribute introduction</a> </h1> <p><img src="/static/imghwm/default1.png" data-src="stickman.gif" class="lazy" style="max-width:90%" style="max-width:90%" alt="href tag in HTML" > HTML href is abbreviated as hypertext reference. This is the attribute which is available inside the anchor (<a>) tag. This href is used for website URLs like www.google.com, www.gmail.com, www.facebook.com etc.</a></p> <p>Real time Example: Day to day life we have accessed so many websites. Have you ever think about how would we access this website URLs? Because of href tag we can access any website URLs. We simply required website within this double quotes (href="website") of href attribute. </p>
Output:
Example #4 – tag with href Attribute
Code:
<title>href attribute</title> <!--Including external CSS styles file with link tag--> <link rel="stylesheet" type="text/css" href="styles.css"> <h1>The <a> tag with href attribute introduction</a> </h1> <p>HTML href is abbreviated as hypertext reference. This is the attribute which is available inside the anchor (<a>) tag. This href is used for website URLs like www.google.com, www.gmail.com, www.facebook.com etc.</a></p> <p>Real time Example: Day to day life we have accessed so many websites. Have you ever think about how would we access this website URLs? Because of href tag we can access any website URLs. We simply required website within this double quotes (href="website") of href attribute. </p>
CSS Code: styles.css
p { color: red; border: 2px solid green; font-size: 22px; } h1 { color: orange; text-align: center; }
Output:
Conclusion
hrefin HTML is used to access the web URLs. There tags that allows the href attribute, those are , , and
Recommended Article
This is a guide to the href tag in HTML. Here we discuss the Introduction to href tag in HTML and its Examples along with code implementation and Output. you can also go through our suggested articles to learn more –
- Top 15 Properties of Span Tag in HTML
- How div Tag Works in HTML?
- HTML Search Bar | Examples
- Canvas Tag in HTML | Examples
The above is the detailed content of href tag in HTML. For more information, please follow other related articles on the PHP Chinese website!

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

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

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

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.

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.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version
Visual web development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.