Class Link
The link element specifies relationships between the current document and an external resource. It is most commonly used to link to stylesheets, but can also be used to establish site icons, prefetch resources, define alternate versions of the document, and more. Link elements are typically placed in the head section of an HTML document.
Examples:
The following convenience methods are provided for constructing instances of this bean:
See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionas attribute.crossorigin(String value) crossorigin attribute.href attribute.hreflang attribute.media attribute.rel attribute.sizes attribute.type attribute.Methods inherited from class org.apache.juneau.bean.html5.HtmlElement
accesskey, attr, attrUri, class_, contenteditable, deminimize, dir, getAttr, getAttr, getAttrs, hidden, id, lang, onabort, onblur, oncancel, oncanplay, oncanplaythrough, onchange, onclick, oncuechange, ondblclick, ondurationchange, onemptied, onended, onerror, onfocus, oninput, oninvalid, onkeydown, onkeypress, onkeyup, onload, onloadeddata, onloadedmetadata, onloadstart, onmousedown, onmouseenter, onmouseleave, onmousemove, onmouseout, onmouseover, onmouseup, onmousewheel, onpause, onplay, onplaying, onprogress, onratechange, onreset, onresize, onscroll, onseeked, onseeking, onselect, onshow, onstalled, onsubmit, onsuspend, ontimeupdate, ontoggle, onvolumechange, onwaiting, self, setAttrs, spellcheck, style, tabindex, title, toString, translate
-
Constructor Details
-
Link
public Link()Creates an emptyLinkelement. -
Link
Creates aLinkelement with the specifiedhref(Object)attribute.- Parameters:
href- Thehref(Object)attribute. Can benull , in which case the attribute is stored with anull value (not removed).
-
-
Method Details
-
as_
as attribute.Specifies the type of content being loaded by a
rel="preload"orrel="modulepreload"link. This allows the browser to prioritize resource loading appropriately.Common values:
"audio" - Audio file"document" - HTML document"fetch" - Resource fetched by fetch or XHR"font" - Font file"image" - Image file"script" - JavaScript file"style" - CSS stylesheet"video" - Video file"worker" - Web worker script
- Parameters:
value- The type of content being loaded. Can benull to unset the attribute.- Returns:
- This object.
-
crossorigin
crossorigin attribute.Specifies how the element handles cross-origin requests for CORS (Cross-Origin Resource Sharing).
Possible values:
"anonymous" - Cross-origin requests are made without credentials"use-credentials" - Cross-origin requests include credentials
- Parameters:
value- How to handle cross-origin requests. Can benull to unset the attribute.- Returns:
- This object.
-
href
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
UriResolvercan be used for values. -
hreflang
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 benull to unset the attribute.- Returns:
- This object.
-
media
media attribute.Specifies which media types the linked resource applies to. Used primarily with stylesheets.
Common values:
"all" - All media types (default)"screen" - Computer screens"print" - Printers and print preview"handheld" - Handheld devices"projection" - Projectors"(max-width: 768px)" - Media queries
- Parameters:
value- The media types the linked resource applies to. Can benull to unset the attribute.- Returns:
- This object.
-
rel
rel attribute.Specifies the relationship between the current document and the linked resource.
Common values:
"stylesheet" - External CSS stylesheet"icon" - Favicon or site icon"canonical" - Canonical URL for SEO"alternate" - Alternative version of the page"preload" - Resource to preload"prefetch" - Resource to prefetch"dns-prefetch" - DNS lookup to prefetch"next" - Next page in a sequence"prev" - Previous page in a sequence
- Parameters:
value- The relationship between the document and linked resource. Can benull to unset the attribute.- Returns:
- This object.
-
sizes
sizes attribute.Specifies the sizes of icons for different device contexts. Used with
rel="icon" orrel="apple-touch-icon" .Common values:
"16x16" - Small favicon"32x32" - Standard favicon"180x180" - Apple touch icon"192x192" - Android icon"512x512" - Large icon"any" - Any size
- Parameters:
value- The sizes of the linked icon resource. Can benull to unset the attribute.- Returns:
- This object.
-
type
type attribute.Specifies the MIME type of the linked resource. Helps browsers determine how to handle the resource.
Common values:
"text/css" - CSS stylesheet"text/javascript" - JavaScript file"application/json" - JSON data"image/png" - PNG image"image/jpeg" - JPEG image"image/svg+xml" - SVG image"font/woff2" - Web font
- Parameters:
value- The MIME type of the linked resource. Can benull to unset the attribute.- Returns:
- This object.
-