HTML Links Hyperlinks
Basic Syntax of a Hyperlink
href
: Specifies the destination URL of the link.Link Text
: The clickable text or content that acts as a link.
1. Link to an External Website
This link takes the user to the external website https://www.example.com
.
2. Link to Another Page on the Same Website
This link takes the user to a page named about.html
within the same website.
3. Open a Link in a New Tab
You can use the target="_blank"
attribute to open a link in a new tab.
4. Link to an Email Address
To create a link that opens the default email client with a pre-filled recipient:
5. Link to a Phone Number (for mobile devices)
For clickable phone numbers, especially useful for mobile users:
6. Link to a Section within the Same Page (Anchor Links)
You can link to specific sections of a page using anchors.
First, create an
id
for the target element:Then, create a link that points to that
id
:
7. Linking to a File (PDF, Image, etc.)
You can link directly to files like PDFs, images, or documents for users to download or view.
8. Link with an Image
Instead of text, you can use an image as a link.
09. Make Part of Text or Paragraph a Link
You can embed a link inside a paragraph or other text elements.
Example Code with Different Types of Links
Summary of Key Attributes:
href
: The URL or path to the link's destination.target="_blank"
: Opens the link in a new tab.title
: Displays a tooltip on hover.download
: Downloads a file instead of opening it.mailto:
: Creates an email link.tel:
: Creates a clickable phone number link.
No comments:
Post a Comment