Class A

Direct Known Subclasses:
Hyperlink

@Marshalled(typeName="a") public class A extends HtmlElementMixed<A>
DTO for an HTML <a> element.

The anchor element creates a hyperlink to other web pages, files, locations within the same page, email addresses, or any other URL. It is one of the most fundamental elements for web navigation.

Examples:

// Simple link to another page A a1 = a().href("https://example.com").text("Visit Example"); // Link with target to open in new window A a2 = a().href("https://example.com").target("_blank").text("Open in New Window"); // Email link A a3 = a().href("mailto:user@example.com").text("Send Email"); // Link with relationship and language A a4 = a().href("https://example.com").rel("nofollow").hreflang("en").text("English Version");

The following convenience methods are provided for constructing instances of this bean:

See Also:
  • Constructor Details

  • Method Details

    • download

      public A download(Object value)
      download attribute.

      Whether to download the resource instead of navigating to it, and its file name if so.

      Parameters:
      value - The new value for this attribute. Typically a Boolean or String. Can be null to unset the attribute.
      Returns:
      This object.
    • href

      public A href(Object value)
      href attribute.

      Address of the hyperlink.

      The value can be of any of the following types: URI, URL, String. Strings must be valid URIs.

      URIs defined by UriResolver can be used for values.

      Parameters:
      value - The new value for this attribute. Typically a URL or String. Can be null, in which case the attribute is stored with a null value (not removed).
      Returns:
      This object.
    • hreflang

      public A hreflang(String value)
      hreflang attribute.

      Specifies the language of the linked resource. Used for SEO and accessibility purposes.

      Examples:

      • "en" - English
      • "es" - Spanish
      • "fr" - French
      • "de" - German
      • "zh" - Chinese
      • "ja" - Japanese
      Parameters:
      value - The language code of the linked resource. Can be null to unset the attribute.
      Returns:
      This object.
    • rel

      public A rel(String value)
      rel attribute.

      Specifies the relationship between the current document and the linked resource.

      Common values:

      • "alternate" - Alternative version of the page
      • "author" - Link to the author of the page
      • "bookmark" - Permalink for bookmarking
      • "external" - External link
      • "help" - Link to help documentation
      • "license" - Link to license information
      • "next" - Next page in a sequence
      • "nofollow" - Don't follow this link for SEO
      • "noreferrer" - Don't send referrer information
      • "prev" - Previous page in a sequence
      • "search" - Link to search functionality
      • "tag" - Tag for the current page
      Parameters:
      value - The relationship between the document and linked resource. Can be null to unset the attribute.
      Returns:
      This object.
    • target

      public A target(String value)
      target attribute.

      Specifies where to open the linked resource when the link is clicked.

      Common values:

      • "_blank" - Open in a new window/tab
      • "_self" - Open in the same frame (default)
      • "_parent" - Open in the parent frame
      • "_top" - Open in the full body of the window
      • "framename" - Open in a named frame
      Parameters:
      value - Where to open the linked resource. Can be null to unset the attribute.
      Returns:
      This object.
    • type

      public A type(String value)
      type attribute.

      Specifies the MIME type of the linked resource. Helps browsers determine how to handle the resource.

      Common values:

      • "text/html" - HTML document
      • "text/css" - CSS stylesheet
      • "application/pdf" - PDF document
      • "image/png" - PNG image
      • "application/zip" - ZIP archive
      Parameters:
      value - The MIME type of the linked resource. Can be null to unset the attribute.
      Returns:
      This object.