Class PhrasingContentElement<T extends PhrasingContentElement<T>>

Direct Known Subclasses:
Abbr, B, Bdi, Bdo, Caption, Cite, Code, Data, Dd, Del, Dfn, Dt, Em, FigCaption, H1, H2, H3, H4, H5, H6, I, Ins, Kbd, Legend, Mark, Meter, Pre, Progress, Q, Rp, Rt, S, Samp, Small, Span, Strong, Sub, Summary, Sup, Time, U, Var

public class PhrasingContentElement<T extends PhrasingContentElement<T>> extends TextElement<T>
Base class for HTML elements whose content model is phrasing content.

Phrasing content elements can contain text and other inline-level elements such as <em>, <strong>, <span>, <a>, <img>, form controls, and other phrasing content. They cannot contain flow-level (block) elements like <div>, <p>, or <table>.

This class extends TextElement to add the ability to contain child elements in addition to text. It exposes element manipulation methods (addElement, setElement, etc.) but does not expose block-level convenience methods like addParagraph or addSpacer, which are available in StyledContainerElement for flow content containers.

Elements that extend this class include headings (<h1>-<h6>), inline text elements (<em>, <strong>, <span>), and other elements whose content model is phrasing content.

Since:
2026
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • PhrasingContentElement

      public PhrasingContentElement(String tagName)
      Creates a new PhrasingContentElement with the specified HTML tag name.
      Parameters:
      tagName - the HTML tag name for this element.
    • PhrasingContentElement

      public PhrasingContentElement(String tagName, String text)
      Creates a new PhrasingContentElement with the specified tag name and text content.
      Parameters:
      tagName - the HTML tag name for this element.
      text - the text content to display.
    • PhrasingContentElement

      public PhrasingContentElement(String tagName, String text, String style)
      Creates a new PhrasingContentElement with the specified tag name, text content, and inline CSS style.
      Parameters:
      tagName - the HTML tag name for this element.
      text - the text content to display.
      style - the inline CSS style string.
    • PhrasingContentElement

      public PhrasingContentElement(String tagName, String text, CssStyle style)
      Creates a new PhrasingContentElement with the specified tag name, text content, and CSS style object.
      Parameters:
      tagName - the HTML tag name for this element.
      text - the text content to display.
      style - the CssStyle object containing style properties.
  • Method Details

    • addElement

      public T addElement(Element child)
      Adds a child element to this element.

      The child is removed from its previous parent if it has one, then added to this element's children. If this element is already attached to a page, the child is also attached and registered for DOM addition.

      Overrides:
      addElement in class Element<T extends PhrasingContentElement<T>>
      Parameters:
      child - The child element to add.
      Returns:
      this element for method chaining
    • setElement

      public T setElement(Element child)
      Replaces all child elements with a single child element.

      All existing children are removed before adding the new child.

      Overrides:
      setElement in class Element<T extends PhrasingContentElement<T>>
      Parameters:
      child - The child element to set as the only child.
      Returns:
      This element for method chaining.
    • insertElement

      public T insertElement(int index, Element child)
      Inserts a child element at the specified index.

      The child is removed from its previous parent if it has one, then inserted at the specified index in this element's children.

      Overrides:
      insertElement in class Element<T extends PhrasingContentElement<T>>
      Parameters:
      index - The index at which to insert the child.
      child - The child element to insert.
      Returns:
      this element for method chaining
    • removeAllElements

      public void removeAllElements()
      Removes all child elements from this element.

      Each child is unlinked and registered for DOM removal if the element is attached to a page.

      Overrides:
      removeAllElements in class Element<T extends PhrasingContentElement<T>>
    • removeElement

      public void removeElement(String id)
      Removes a child element by its ID.
      Overrides:
      removeElement in class Element<T extends PhrasingContentElement<T>>
      Parameters:
      id - The ID of the child element to remove.
    • removeElement

      public void removeElement(Element child)
      Removes a child element from this element.

      The child is unlinked from this parent and registered for DOM removal if the element is attached to a page.

      Overrides:
      removeElement in class Element<T extends PhrasingContentElement<T>>
      Parameters:
      child - The child element to remove.