88import j2html .tags .InlineStaticResource ;
99import j2html .tags .Text ;
1010import j2html .tags .UnescapedText ;
11+ import j2html .tags .specialized .BodyTag ;
12+ import j2html .tags .specialized .HeadTag ;
13+ import j2html .tags .specialized .HtmlTag ;
14+
1115import java .util .Collection ;
1216import java .util .List ;
1317import java .util .Map ;
@@ -165,11 +169,8 @@ public static Text text(String text) {
165169 * @param htmlTag the html content of a website
166170 * @return document declaration and rendered html content
167171 */
168- public static String document (ContainerTag htmlTag ) {
169- if (htmlTag .getTagName ().equals ("html" )) {
170- return document ().render () + htmlTag .render ();
171- }
172- throw new IllegalArgumentException ("Only HTML-tag can follow document declaration" );
172+ public static String document (HtmlTag htmlTag ) {
173+ return document ().render () + htmlTag .render ();
173174 }
174175
175176 //Special tags
@@ -571,28 +572,28 @@ public static ContainerTag blockquote(Attr.ShortForm shortAttr, DomContent... dc
571572 return Attr .addTo (new ContainerTag ("blockquote" ).with (dc ), shortAttr );
572573 }
573574
574- public static ContainerTag body () {
575- return new ContainerTag ( "body" );
575+ public static BodyTag body () {
576+ return new BodyTag ( );
576577 }
577578
578- public static ContainerTag body (String text ) {
579- return new ContainerTag ( "body" ).withText (text );
579+ public static BodyTag body (String text ) {
580+ return ( BodyTag ) new BodyTag ( ).withText (text );
580581 }
581582
582- public static ContainerTag body (DomContent ... dc ) {
583- return new ContainerTag ( "body" ).with (dc );
583+ public static BodyTag body (DomContent ... dc ) {
584+ return ( BodyTag ) new BodyTag ( ).with (dc );
584585 }
585586
586- public static ContainerTag body (Attr .ShortForm shortAttr ) {
587- return Attr .addTo (new ContainerTag ( "body" ), shortAttr );
587+ public static BodyTag body (Attr .ShortForm shortAttr ) {
588+ return ( BodyTag ) Attr .addTo (new BodyTag ( ), shortAttr );
588589 }
589590
590- public static ContainerTag body (Attr .ShortForm shortAttr , String text ) {
591- return Attr .addTo (new ContainerTag ( "body" ).withText (text ), shortAttr );
591+ public static BodyTag body (Attr .ShortForm shortAttr , String text ) {
592+ return ( BodyTag ) Attr .addTo (new BodyTag ( ).withText (text ), shortAttr );
592593 }
593594
594- public static ContainerTag body (Attr .ShortForm shortAttr , DomContent ... dc ) {
595- return Attr .addTo (new ContainerTag ( "body" ).with (dc ), shortAttr );
595+ public static BodyTag body (Attr .ShortForm shortAttr , DomContent ... dc ) {
596+ return ( BodyTag ) Attr .addTo (new BodyTag ( ).with (dc ), shortAttr );
596597 }
597598
598599 public static ContainerTag button () {
@@ -1243,28 +1244,28 @@ public static ContainerTag h6(Attr.ShortForm shortAttr, DomContent... dc) {
12431244 return Attr .addTo (new ContainerTag ("h6" ).with (dc ), shortAttr );
12441245 }
12451246
1246- public static ContainerTag head () {
1247- return new ContainerTag ( "head" );
1247+ public static HeadTag head () {
1248+ return new HeadTag ( );
12481249 }
12491250
1250- public static ContainerTag head (String text ) {
1251- return new ContainerTag ( "head" ).withText (text );
1251+ public static HeadTag head (String text ) {
1252+ return ( HeadTag ) new HeadTag ( ).withText (text );
12521253 }
12531254
1254- public static ContainerTag head (DomContent ... dc ) {
1255- return new ContainerTag ( "head" ).with (dc );
1255+ public static HeadTag head (DomContent ... dc ) {
1256+ return ( HeadTag ) new HeadTag ( ).with (dc );
12561257 }
12571258
1258- public static ContainerTag head (Attr .ShortForm shortAttr ) {
1259- return Attr .addTo (new ContainerTag ( "head" ), shortAttr );
1259+ public static HeadTag head (Attr .ShortForm shortAttr ) {
1260+ return ( HeadTag ) Attr .addTo (new HeadTag ( ), shortAttr );
12601261 }
12611262
1262- public static ContainerTag head (Attr .ShortForm shortAttr , String text ) {
1263- return Attr .addTo (new ContainerTag ( "head" ).withText (text ), shortAttr );
1263+ public static HeadTag head (Attr .ShortForm shortAttr , String text ) {
1264+ return ( HeadTag ) Attr .addTo (new HeadTag ( ).withText (text ), shortAttr );
12641265 }
12651266
1266- public static ContainerTag head (Attr .ShortForm shortAttr , DomContent ... dc ) {
1267- return Attr .addTo (new ContainerTag ( "head" ).with (dc ), shortAttr );
1267+ public static HeadTag head (Attr .ShortForm shortAttr , DomContent ... dc ) {
1268+ return ( HeadTag ) Attr .addTo (new HeadTag ( ).with (dc ), shortAttr );
12681269 }
12691270
12701271 public static ContainerTag header () {
@@ -1291,28 +1292,36 @@ public static ContainerTag header(Attr.ShortForm shortAttr, DomContent... dc) {
12911292 return Attr .addTo (new ContainerTag ("header" ).with (dc ), shortAttr );
12921293 }
12931294
1294- public static ContainerTag html () {
1295- return new ContainerTag ("html" );
1295+ public static HtmlTag html () {
1296+ return new HtmlTag ();
1297+ }
1298+
1299+ public static HtmlTag html (Attr .ShortForm shortAttr ) {
1300+ return Attr .addTo (new HtmlTag (), shortAttr );
1301+ }
1302+
1303+ public static HtmlTag html (HeadTag head ){
1304+ return new HtmlTag (head );
12961305 }
12971306
1298- public static ContainerTag html (String text ) {
1299- return new ContainerTag ( "html" ). withText ( text );
1307+ public static HtmlTag html (BodyTag body ) {
1308+ return new HtmlTag ( body );
13001309 }
13011310
1302- public static ContainerTag html (DomContent ... dc ) {
1303- return new ContainerTag ( "html" ). with ( dc );
1311+ public static HtmlTag html (HeadTag head , BodyTag body ) {
1312+ return new HtmlTag ( head , body );
13041313 }
13051314
1306- public static ContainerTag html (Attr .ShortForm shortAttr ) {
1307- return Attr .addTo (new ContainerTag ( "html" ), shortAttr );
1315+ public static HtmlTag html (Attr .ShortForm shortAttr , HeadTag head ) {
1316+ return Attr .addTo (new HtmlTag ( head ), shortAttr );
13081317 }
13091318
1310- public static ContainerTag html (Attr .ShortForm shortAttr , String text ) {
1311- return Attr .addTo (new ContainerTag ( "html" ). withText ( text ), shortAttr );
1319+ public static HtmlTag html (Attr .ShortForm shortAttr , BodyTag body ) {
1320+ return Attr .addTo (new HtmlTag ( body ), shortAttr );
13121321 }
13131322
1314- public static ContainerTag html (Attr .ShortForm shortAttr , DomContent ... dc ) {
1315- return Attr .addTo (new ContainerTag ( "html" ). with ( dc ), shortAttr );
1323+ public static HtmlTag html (Attr .ShortForm shortAttr , HeadTag head , BodyTag body ) {
1324+ return Attr .addTo (new HtmlTag ( head , body ), shortAttr );
13161325 }
13171326
13181327 public static ContainerTag i () {
0 commit comments