Anchor(Links) and Button

Hyperlink

Basic Link Example

<a href="https://https://rajeshrathod.com">Visit Rajesh's Website</a>

Here href → Specifies the link’s destination.

Relative & Absolute URLs

The <a> (Anchor) Tag

The <a> tag creates hyperlinks to other pages or websites.

Opening a Link in a New Tab

By default, links are opened in same tab.

<a href="https://https://rajeshrathod.com" target="_blank">Visit Rajesh's Website</a>

Here target="_blank" → Opens the link in a new tab.

Linking to Another Page on Your Website

If you create a file about.html in the same folder, this link will open it.

<a href="about.html">Go to About Page</a>

Linking to a Section on the Same Page

<a href="#section2">Go to Section 2</a>

<h2 id="section2">Section 2</h2>
<p>This is Section 2.</p>
  • id="section2" → Creates a named section.
  • href="#section2" → Jumps to that section.