Class Article<T extends Article<T>>


public class Article<T extends Article<T>> extends StyledContainerElement<T>
Represents the HTML <article> element for independent, self-contained content.

The Article class provides a Java representation of the HTML5 article element, which defines independent, self-contained content that could be distributed separately from the rest of the site. Examples include blog posts, news articles, forum posts, product cards, and user comments.

Features:

  • Semantic HTML5 structural element
  • Self-contained, independent content
  • Improved accessibility and SEO
  • Can be nested within sections or other articles
  • Typically contains headings and publication info
  • Full CSS styling capabilities

Usage Example:


 // Create a blog post article
 Article blogPost = new Article();
 blogPost.addElement(new H2("10 Tips for Better Code"));
 blogPost.addElement(new P("By John Doe - Jan 15, 2024"));
 blogPost.addElement(new P("Here are some tips..."));

 // Create a news article
 Article newsArticle = new Article();
 newsArticle.setClass("news-item");
 Header articleHeader = new Header();
 articleHeader.addElement(new H3("Breaking News"));
 newsArticle.addElement(articleHeader);
 newsArticle.addElement(new P("The story content..."));

 // Create a product card
 Article productCard = new Article();
 productCard.setClass("product-card");
 productCard.addElement(new Img("/product.jpg"));
 productCard.addElement(new H4("Product Name"));
 productCard.addElement(new P("$19.99"));
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Article

      public Article()
      Creates a new Article element for independent, self-contained content.