001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.bean.html5; 018 019import org.apache.juneau.marshall.*; 020 021/** 022 * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#the-head-element"><head></a> 023 * element. 024 * 025 * <p> 026 * The head element represents a collection of metadata for the document. It is used to contain 027 * information about the document that is not displayed as part of the document's content, such 028 * as the title, links to stylesheets, scripts, and other metadata. The head element is typically 029 * placed immediately after the opening html tag and before the body element. It can contain 030 * elements like title, meta, link, style, script, and base. 031 * 032 * <h5 class='section'>Examples:</h5> 033 * <p class='bcode w800'> 034 * <jk>import static</jk> org.apache.juneau.bean.html5.HtmlBuilder.*; 035 * 036 * <jc>// Simple head with title</jc> 037 * Head <jv>simple</jv> = <jsm>head</jsm>( 038 * <jsm>title</jsm>(<js>"My Website"</js>), 039 * <jsm>meta</jsm>().charset(<js>"UTF-8"</js>) 040 * ); 041 * 042 * <jc>// Head with styling</jc> 043 * Head <jv>styled</jv> = <jsm>head</jsm>( 044 * <jsm>title</jsm>(<js>"Styled Page"</js>), 045 * <jsm>meta</jsm>().charset(<js>"UTF-8"</js>), 046 * <jsm>link</jsm>().rel(<js>"stylesheet"</js>).href(<js>"/css/style.css"</js>) 047 * ); 048 * 049 * <jc>// Head with complex content</jc> 050 * Head <jv>complex</jv> = <jsm>head</jsm>( 051 * <jsm>title</jsm>(<js>"Complete Page"</js>), 052 * <jsm>meta</jsm>().charset(<js>"UTF-8"</js>), 053 * <jsm>meta</jsm>().name(<js>"viewport"</js>).content(<js>"width=device-width, initial-scale=1.0"</js>), 054 * <jsm>link</jsm>().rel(<js>"stylesheet"</js>).href(<js>"/css/main.css"</js>), 055 * <jsm>link</jsm>().rel(<js>"icon"</js>).href(<js>"/favicon.ico"</js>), 056 * <jsm>script</jsm>().src(<js>"/js/main.js"</js>) 057 * ); 058 * 059 * <jc>// Head with ID</jc> 060 * Head <jv>withId</jv> = <jsm>head</jsm>( 061 * <jsm>title</jsm>(<js>"Page with ID"</js>), 062 * <jsm>meta</jsm>().charset(<js>"UTF-8"</js>) 063 * ).id(<js>"page-head"</js>); 064 * 065 * <jc>// Head with styling</jc> 066 * Head <jv>styled2</jv> = <jsm>head</jsm>( 067 * <jsm>title</jsm>(<js>"Styled Head"</js>), 068 * <jsm>meta</jsm>().charset(<js>"UTF-8"</js>) 069 * ).style(<js>"background-color: #f0f0f0;"</js>); 070 * 071 * <jc>// Head with multiple elements</jc> 072 * Head <jv>multiple</jv> = <jsm>head</jsm>( 073 * <jsm>title</jsm>(<js>"Multi-Element Head"</js>), 074 * <jsm>meta</jsm>().charset(<js>"UTF-8"</js>), 075 * <jsm>meta</jsm>().name(<js>"description"</js>).content(<js>"A comprehensive page"</js>), 076 * <jsm>link</jsm>().rel(<js>"stylesheet"</js>).href(<js>"/css/reset.css"</js>), 077 * <jsm>link</jsm>().rel(<js>"stylesheet"</js>).href(<js>"/css/layout.css"</js>), 078 * <jsm>script</jsm>().src(<js>"/js/jquery.js"</js>), 079 * <jsm>script</jsm>().src(<js>"/js/app.js"</js>) 080 * ); 081 * 082 * <jc>// Head with base element</jc> 083 * Head <jv>withBase</jv> = <jsm>head</jsm>( 084 * <jsm>title</jsm>(<js>"Page with Base"</js>), 085 * <jsm>meta</jsm>().charset(<js>"UTF-8"</js>), 086 * <jsm>base</jsm>().href(<js>"https://example.com/"</js>), 087 * <jsm>link</jsm>().rel(<js>"stylesheet"</js>).href(<js>"css/style.css"</js>) 088 * ); 089 * </p> 090 * 091 * <p> 092 * The following convenience methods are provided for constructing instances of this bean: 093 * <ul class='javatree'> 094 * <li class='jc'>{@link HtmlBuilder} 095 * <ul class='javatree'> 096 * <li class='jm'>{@link HtmlBuilder#head() head()} 097 * <li class='jm'>{@link HtmlBuilder#head(Object...) head(Object...)} 098 * </ul> 099 * </ul> 100 * </p> 101 * 102 * <h5 class='section'>See Also:</h5><ul> 103 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a> 104 * </ul> 105 */ 106@Marshalled(typeName = "head") 107public class Head extends HtmlElementContainer<Head> { 108 109 /** 110 * Creates an empty {@link Head} element. 111 */ 112 public Head() {} 113 114 /** 115 * Creates a {@link Head} element with the specified child nodes. 116 * 117 * @param children The child nodes. 118 */ 119 public Head(Object...children) { 120 children(children); 121 } 122 123}