HTML Tag - GeeksforGeeks
Có thể bạn quan tâm
The <a> tag defines a hyperlink, which is used to link from one page to another. The most important attribute of the <a> element is the href attribute, which indicates the link’s destination. This attribute determines where the user is directed upon clicking the link.
HTML <a href="https://www.geeksforgeeks.org/html-tutorials/"> html tutorial </a>Syntax:
<a href = "link"> Link Name </a>By default, links appear as follows in all browsers:
- Unvisited links: Underlined and blue.
- Visited links: Underlined and purple.
- Active links: Underlined and red.
1. Opening Links in New Tab:
To open a link in a new browser Tab, add the target=”_blank” attribute:
HTML <a href="https://www.geeksforgeeks.org" target="_blank">GeeksforGeeks</a>2. Linking to Email Addresses and Phone Numbers:
- To link to an email address:
- To link to a phone number:
3. Creating Internal Page Anchors
To link to another section on the same page:
HTML <a href="#section1">Go to Section 1</a>4. Executing JavaScript
To trigger JavaScript code:
HTML <a href="javascript:alert('Hello Geek');">Execute JavaScript</a>Attributes:
Attributes | Description |
---|---|
charset | It specifies the character set. It is not supported by HTML 5. |
download | It is used to specify the target link to download when the user clicks. |
hreflang | It is used to specify the language of the linked document. |
media | It is used to specify the linked media. |
name | It is used to specify the anchor name. It is not supported by HTML 5 you can use the global id attribute instead. |
rel | It is used to specify the relation between the current document and the linked document. |
shape | It is used to specify the shape of the link. It is not supported by HTML 5. |
type | It is used to specify the type of links. |
target | It specifies the target link. |
rev | It is used to specify the relation between the linked document and the current document. It is not supported by HTML 5. |
HTML <a> tag – FAQs
What does the target=”_blank” attribute do in the <a> tag?
The target=”_blank” attribute opens the linked document in a new browser tab or window.
Can the <a> tag be used for linking to sections within the same page?
Yes, you can link to sections using an ID with the href attribute: <a href=”#section-id”>Go to Section</a>.
Can the <a> tag be used without the href attribute?
Yes, but without href, the link is inactive and functions more like a clickable placeholder or button, depending on the styling.
What is the purpose of the rel=”noopener noreferrer” attribute with target=”_blank”?
shivangsharma15 Follow Improve Previous Article HTML address Tag Next Article HTML applet TagIt improves security and performance by preventing the new page from accessing the original page’s window object.
Từ khóa » Html Tag For Website
-
HTML A Tag - W3Schools
-
HTML Element Reference - By Category - W3Schools
-
: The Anchor Element - HTML: HyperText Markup Language | MDN
-
HTML Elements Reference - HTML: HyperText Markup Language
-
Some Commonly Used HTML Tags - Columbia University
-
HTML Tags - CSUN
-
HTML Tags - Javatpoint
-
7 Essential HTML Tags That Separate SEO Pros From The Rookies
-
WebD2: Common HTML Tags - University Of Washington
-
WebD2: Essential Tags - University Of Washington
-
HTML And CSS Tutorial - Nanyang Technological University
-
Basic HTML Tags - Top 10 Tags - CodeBrainer
-
How To Determine Tags On A Website - Small Business