Class Paragraph<T extends Paragraph<T>>

All Implemented Interfaces:
HgroupElement

public class Paragraph<T extends Paragraph<T>> extends P<T>
Represents an HTML paragraph element, providing a semantic alias for P.

The Paragraph class is a convenience wrapper that extends P, providing a more descriptive class name for developers who prefer explicit naming. It represents a paragraph of text in an HTML document and offers identical functionality to the P class.

Features:

  • Identical functionality to P
  • More descriptive class name
  • Semantic representation of paragraph text blocks
  • Supports text content and nested HTML elements
  • Full styling support through inherited methods
  • Automatic spacing between paragraphs

Usage:


 // Simple text paragraph
 Paragraph intro = new Paragraph("Welcome to our website!");

 // Empty paragraph for later content
 Paragraph content = new Paragraph();
 content.addText("This paragraph was created empty.");
 content.addText(" Additional text can be added.");

 // Paragraph with nested element
 Strong emphasis = new Strong("important");
 Paragraph notice = new Paragraph("This is an ");
 notice.addElement(emphasis);
 notice.addText(" message.");

 // Styled paragraph
 Paragraph styled = new Paragraph("Styled text");
 styled.setTextAlign("center");
 styled.setColor("#336699");
 
Since:
2016
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • P
  • invalid reference
    PhrasingContentElement
  • Constructor Details

    • Paragraph

      public Paragraph()
      Constructs a new empty Paragraph element.

      Creates an HTML <p> element with no initial content. Text and other elements can be added after construction.

    • Paragraph

      public Paragraph(String text)
      Constructs a new Paragraph element with the specified text content.

      Creates an HTML <p> element containing the specified text. This is a convenience constructor for creating simple text paragraphs.

      Parameters:
      text - the text content for the paragraph
    • Paragraph

      public Paragraph(Element element)
      Constructs a new Paragraph element containing the specified HTML element.

      Creates an HTML <p> element that wraps or contains the specified HTML element. This is useful for creating paragraphs with nested elements like images, links, or formatted text.

      Parameters:
      element - the HTML element to include in the paragraph