HTML links are used to connect different pages or sections within a website. They allow users to navigate from one page to another by clicking on a hyperlink. The most basic syntax of an HTML link is as follows:
<a href="URL">Link text</a>
Here, URL
is the address of the page or section you want to link to and Link text
the text will be displayed on the page as a clickable hyperlink.
For example, to link to Google’s homepage, the code would look like this:
<a href="https://www.google.com">Go to Google</a>
It’s also possible to link to other types of files, such as PDFs or images, by specifying the URL of the file in the href
Attribute. For example:
<a href="my-document.pdf">Download PDF</a>
Links can also jump to specific sections within the same page. To do this, you need to give the section a unique id
and then use that id
in the href
Attribute of the link. For example:
<h2 id="section1">Section 1</h2>
...
<a href="#section1">Go to Section 1</a>
That’s a basic introduction to HTML links. I hope this helps you start using links on your web pages!