Class Main


@Bean(typeName="main") public class Main extends HtmlElementContainer
DTO for an HTML <main> element.

The main element represents the main content of the body of a document or application. It is used to identify the primary content of the page, excluding content that is repeated across multiple pages such as navigation, headers, footers, and sidebars. The main element should be used only once per page and contains the central topic or functionality of the page. It is important for accessibility and helps screen readers identify the main content area.

Examples:

// Simple main content Main simple = main( h1("Welcome to Our Site"), p("This is the main content of our page.") ); // Main with styling Main styled = main( h1("About Us"), p("Learn more about our company and mission.") )._class("main-content"); // Main with complex content Main complex = main( h1("Product Catalog"), section( h2("Featured Products"), p("Check out our latest offerings.") ), section( h2("Categories"), ul( li("Electronics"), li("Clothing"), li("Books") ) ) ); // Main with ID Main withId = main( h1("Main Content"), p("This is the main content area.") ).id("page-main"); // Main with styling Main styled2 = main( h1("Centered Content"), p("This content is centered and styled.") ).style("max-width: 800px; margin: 0 auto; padding: 20px;"); // Main with multiple sections Main multiSection = main( section( h1("Page Title"), p("Introduction to the page content.") ), section( h2("Content Section"), p("Detailed content goes here.") ), section( h2("Conclusion"), p("Summary and closing thoughts.") ) ); // Main with article Main withArticle = main( article( h1("Article Title"), p("Article content goes here."), footer("Article footer") ) );

See Also: