Class Div


@Bean(typeName="div") public class Div extends HtmlElementMixed
DTO for an HTML <div> element.

The div element represents a generic container for flow content. It is used to group elements together for styling purposes or to create layout structures. The div element has no semantic meaning and is purely presentational, making it a versatile tool for organizing and styling content. It is commonly used with CSS to create layouts, group related elements, or apply styling to multiple elements at once.

Examples:

import static org.apache.juneau.bean.html5.HtmlBuilder.*; // Simple div Div simple = div("Hello World"); // Div with styling Div styled = div() ._class("container") .style("padding: 20px; background-color: #f0f0f0;"); // Div with multiple children Div multiple = div( h1("Title"), p("Content"), p("More content") ); // Div with complex content Div complex = div( div()._class("card-header").children("Card Title"), div()._class("card-body").children("Card content"), div()._class("card-footer").children("Card footer") )._class("card"); // Div with ID Div withId = div("Main content area") .id("main-content"); // Div with styling Div styled2 = div( div()._class("left-column").children("Left content"), div()._class("right-column").children("Right content") ).style("display: flex; justify-content: space-between;"); // Div with event handlers Div interactive = div("Interactive div") .onclick("handleClick()") .onmouseover("handleMouseOver()");

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

See Also: