Cover Image for How to add Link in Html
110 views

How to add Link in Html

To add a link (hyperlink) in HTML, you can use the <a> (anchor) element along with the href attribute. Here’s how you can do it:

HTML<span role="button" tabindex="0" data-code="<a href="https://www.example.com">Link Text
<a href="https://www.example.com">Link Text</a>

In the above example, the href attribute specifies the URL or destination where the link should point to. Replace "https://www.example.com" with the actual URL you want to link to.

You can also use relative URLs to link to pages within your own website or specify the path to a local file. Here’s an example of a relative URL:

HTML<span role="button" tabindex="0" data-code="<a href="/about.html">About
<a href="/about.html">About</a>

In this case, the link points to an HTML file named “about.html” located in the root directory of the website.

Additionally, you can add optional attributes to customize the behavior or appearance of the link. For example, the target attribute can be used to specify where the linked page should open:

HTML
<a href="https://www.example.com" target="_blank">Link Text</a>

In this case, the target="_blank" attribute value tells the browser to open the linked page in a new tab or window.

You can also use other attributes like title to add a tooltip text, class to assign CSS classes for styling, and more. Experiment with different attributes to achieve the desired functionality and appearance.

Remember to properly format the link text between the opening <a> and closing </a> tags. The link text will be displayed as clickable text on the webpage.

By adding links in HTML, you can create navigation menus, connect pages within your website, or link to external resources, enhancing the interactivity and usability of your web pages.

YOU MAY ALSO LIKE...

The Tech Thunder

The Tech Thunder

The Tech Thunder


COMMENTS