The HTMLHead class represents an HTML head tag. The head section of an HTML page features an opening and closing head tag that typically contains other tags. Typically, the head tag contains a title tag and possibly meta tags.
Constructors for HTMLHead enable you to construct a head tag that is empty, that contains a title tag, or that contains a title tag and a meta tag. You can easily add title and meta tags to the empty HTMLHead object.
Methods for the HTMLHead class include setting and getting the page title and the meta tags. Define the contents of the meta tags by using the HTMLMeta class. For more information about the HTMLMeta class, see the following page:
HTMLMeta
The following code shows one way to create an HTMLHead tag:
// Create an empty HTMLHead. HTMLHead head = new HTMLHead("My Main Page"); // Add the title. head.setTitle("My main page"); // Define your meta information and add it to HTMLHead. HTMLMeta meta = new HTMLMeta("Content-Type", "text/html; charset=iso-8859-1"); head.addMetaInformation(meta);
This is the output of the example HTMLHead tag:
<head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> <title>My main page</title> </head>
For more information about using the HTMLHead class, see the following Javadoc reference documentation:
HTMLHead