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/grouping-content.html#the-div-element"><div></a> 023 * element. 024 * 025 * <p> 026 * The div element represents a generic container for flow content. It is used to group elements 027 * together for styling purposes or to create layout structures. The div element has no semantic 028 * meaning and is purely presentational, making it a versatile tool for organizing and styling 029 * content. It is commonly used with CSS to create layouts, group related elements, or apply 030 * styling to multiple elements at once. 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 div</jc> 037 * Div <jv>simple</jv> = <jsm>div</jsm>(<js>"Hello World"</js>); 038 * 039 * <jc>// Div with styling</jc> 040 * Div <jv>styled</jv> = <jsm>div</jsm>() 041 * .class_(<js>"container"</js>) 042 * .style(<js>"padding: 20px; background-color: #f0f0f0;"</js>); 043 * 044 * <jc>// Div with multiple children</jc> 045 * Div <jv>multiple</jv> = <jsm>div</jsm>( 046 * <jsm>h1</jsm>(<js>"Title"</js>), 047 * <jsm>p</jsm>(<js>"Content"</js>), 048 * <jsm>p</jsm>(<js>"More content"</js>) 049 * ); 050 * 051 * <jc>// Div with complex content</jc> 052 * Div <jv>complex</jv> = <jsm>div</jsm>( 053 * <jsm>div</jsm>().class_(<js>"card-header"</js>).children(<js>"Card Title"</js>), 054 * <jsm>div</jsm>().class_(<js>"card-body"</js>).children(<js>"Card content"</js>), 055 * <jsm>div</jsm>().class_(<js>"card-footer"</js>).children(<js>"Card footer"</js>) 056 * ).class_(<js>"card"</js>); 057 * 058 * <jc>// Div with ID</jc> 059 * Div <jv>withId</jv> = <jsm>div</jsm>(<js>"Main content area"</js>) 060 * .id(<js>"main-content"</js>); 061 * 062 * <jc>// Div with styling</jc> 063 * Div <jv>styled2</jv> = <jsm>div</jsm>( 064 * <jsm>div</jsm>().class_(<js>"left-column"</js>).children(<js>"Left content"</js>), 065 * <jsm>div</jsm>().class_(<js>"right-column"</js>).children(<js>"Right content"</js>) 066 * ).style(<js>"display: flex; justify-content: space-between;"</js>); 067 * 068 * <jc>// Div with event handlers</jc> 069 * Div <jv>interactive</jv> = <jsm>div</jsm>(<js>"Interactive div"</js>) 070 * .onclick(<js>"handleClick()"</js>) 071 * .onmouseover(<js>"handleMouseOver()"</js>); 072 * </p> 073 * 074 * <p> 075 * The following convenience methods are provided for constructing instances of this bean: 076 * <ul class='javatree'> 077 * <li class='jc'>{@link HtmlBuilder} 078 * <ul class='javatree'> 079 * <li class='jm'>{@link HtmlBuilder#div() div()} 080 * <li class='jm'>{@link HtmlBuilder#div(Object...) div(Object...)} 081 * </ul> 082 * </ul> 083 * </p> 084 * 085 * <h5 class='section'>See Also:</h5><ul> 086 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a> 087 * </ul> 088 */ 089@Marshalled(typeName = "div") 090public class Div extends HtmlElementMixed<Div> { 091 092 /** 093 * Creates an empty {@link Div} element. 094 */ 095 public Div() {} 096 097 /** 098 * Creates a {@link Div} element with the specified child nodes. 099 * 100 * @param children The child nodes. 101 */ 102 public Div(Object...children) { 103 children(children); 104 } 105 106}