Generate HTML Links for Your Website

Choose a web, email, or telephone link, enter its destination and visible text, and copy the generated HTML anchor tag into your page. For web links, you can select where the destination opens, request a file download, and set link relationships.

The generator also provides Python code to create and save a link in an HTML document with Aspose.HTML for Python via .NET . The link text and attributes update with your selected settings.


HTML Hyperlink Generator Settings

  • Type selects Web URL, Email (mailto), or Telephone (tel). Enter the destination in URL, Email, or Telephone, respectively. For an external webpage, include the https:// scheme.
  • Text sets the visible, clickable label. Describe the destination or action so visitors know what to expect. This field accepts plain text rather than HTML markup.
  • Target is available for web links. Use _self for the current tab or _blank for a new tab or window. The _parent and _top values navigate the parent or top-level browsing context when your page is inside a frame.
  • Download adds the download attribute to a web link. It requests a file download, but browser rules and server responses affect the result, especially for files hosted on a different origin.
  • Isolate opened page (noopener) adds rel="noopener", preventing the opened page from accessing the original window through window.opener. Do not send referrer info adds noreferrer to suppress the referring address.
  • Do not endorse (nofollow) marks a link you do not endorse. External link identifies a destination outside the current site, and Help link identifies context-sensitive help. These switches add relationship tokens; they do not change the link’s visible styling.

Target, download, and relationship settings apply to Web URL links. Email and telephone links use mailto: and tel: destinations without those extra attributes. See the HTML link relationship reference for the meaning of each relationship.


Create an HTML Hyperlink in Python

Use HTMLDocument to create a document and an <a> element. The example assigns its destination and text, applies the selected attributes, appends the link to the document body, and saves the HTML file.

Choose the appropriate link type before copying the Python code. A relative web address is resolved from the page’s location; use a complete URL when the destination is on another website.

Python Code
import aspose.html

with aspose.html.HTMLDocument() as document:
    anchor = document.create_element("a")
    anchor.set_attribute("href", "https://www.aspose.com/")
    anchor.text_content = "Visit Aspose"
    anchor.set_attribute("target", "_blank")
    anchor.set_attribute("rel", "noopener")

    document.body.append_child(anchor)
    document.save("hyperlink.html")

Steps to Create an HTML Hyperlink in Python

  1. Create an HTMLDocument and call create_element() with "a".
  2. Set href with set_attribute() . Use a web address, a mailto: destination, or a tel: destination as appropriate.
  3. Assign the visible label through text_content . Apply optional target, download, and rel attributes for a web link.
  4. Append the anchor to document.body with append_child() .
  5. Save the HTML document with save() . The with statement closes the document automatically.

HTML Hyperlink Generator FAQ

1. How do I link to a section on the same HTML page?

Give the destination element a unique id, such as contact. Select Web URL, enter #contact in URL, and choose _self as the target. After adding the generated link to your page, clicking it navigates to the element with the matching ID. The generator creates the link; add the destination ID to the relevant heading or section yourself.

2. Why does my email or telephone link not open an app?

Email and telephone links rely on an application registered to handle mailto: or tel: addresses on the visitor’s device. If no compatible app is configured, clicking may prompt the visitor to choose one or may have no useful result. An email link opens a message composer rather than sending mail automatically; telephone behavior depends on the device and available calling apps. See the HTML anchor reference for link types.

3. How do I change an HTML link’s color or remove its underline?

Add a CSS class to the generated <a> element and style that class in your stylesheet. Use color for the text color and text-decoration to control the underline. If you remove the underline, provide another clear visual cue that the text is a link and keep a visible keyboard-focus indicator. The generator does not include styling controls.


Install Aspose.HTML for Python via .NET

Install the aspose-html-net package from PyPI .

Install Aspose.HTML for Python via .NET

pip install aspose-html-net

Review the installation guide and system requirements before deployment. Request a temporary license to test the API without evaluation limitations.