The most basic syntax for creating an HTML link is as follows:
Here is an example of a basic HTML link:
When you click on the link, you will be taken to the Google homepage.
If you want to link to another page on the same site, you can use a relative URL. A relative URL is a URL that is relative to the current page. For example, if you are on the home page of a website, and you want to link to the "About" page, you can use a relative URL like this:
The href
attribute of the <a>
tag is set to about.html
.
This means that the link will take you to a page called about.html
in the same directory as
the current page. If you are on the "About" page, and you want to link back to the home page, you can use
a relative URL like this:
The href
attribute of the <a>
tag is set to index.html
.
This means that the link will take you to a page called index.html
in the same directory as
the current page.
If you want to link to another website, you can use an absolute URL. An absolute URL is a URL that contains the full address of the page you want to link to. For example, if you want to link to the TXON home page, you can use an absolute URL like this:
The href
attribute of the <a>
tag is set to
https://www.txon.in/
. This means that the link will take you to the W3Schools home
page.
If you want to link to an email address, you can use the mailto:
URL scheme. For example, if
you want to link to the email address
, you can use an absolute URL like this:
The href
attribute of the <a>
tag is set to mailto:
. This means that the link will open the user's email program, and the email address will be filled in.
If you want to link to a specific part of the same page, you can use the id
attribute of the
HTML element you want to link to. For example, if you want to link to the "Android Development" section,
you can use an absolute URL like this: