Class Head


@Bean(typeName="head") public class Head extends HtmlElementContainer
DTO for an HTML <head> element.

The head element represents a collection of metadata for the document. It is used to contain information about the document that is not displayed as part of the document's content, such as the title, links to stylesheets, scripts, and other metadata. The head element is typically placed immediately after the opening html tag and before the body element. It can contain elements like title, meta, link, style, script, and base.

Examples:

import static org.apache.juneau.bean.html5.HtmlBuilder.*; // Simple head with title Head simple = head( title("My Website"), meta().charset("UTF-8") ); // Head with styling Head styled = head( title("Styled Page"), meta().charset("UTF-8"), link().rel("stylesheet").href("/css/style.css") ); // Head with complex content Head complex = head( title("Complete Page"), meta().charset("UTF-8"), meta().name("viewport").content("width=device-width, initial-scale=1.0"), link().rel("stylesheet").href("/css/main.css"), link().rel("icon").href("/favicon.ico"), script().src("/js/main.js") ); // Head with ID Head withId = head( title("Page with ID"), meta().charset("UTF-8") ).id("page-head"); // Head with styling Head styled2 = head( title("Styled Head"), meta().charset("UTF-8") ).style("background-color: #f0f0f0;"); // Head with multiple elements Head multiple = head( title("Multi-Element Head"), meta().charset("UTF-8"), meta().name("description").content("A comprehensive page"), link().rel("stylesheet").href("/css/reset.css"), link().rel("stylesheet").href("/css/layout.css"), script().src("/js/jquery.js"), script().src("/js/app.js") ); // Head with base element Head withBase = head( title("Page with Base"), meta().charset("UTF-8"), base().href("https://example.com/"), link().rel("stylesheet").href("css/style.css") );

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

See Also: