Class Span<T extends Span<T>>

Direct Known Subclasses:
VisuallyHidden

public class Span<T extends Span<T>> extends PhrasingContentElement<T>
Java representation of the HTML <span> element.

The Span class represents an inline container element used for styling portions of text or grouping inline elements. Unlike Div, span is an inline element that doesn't create a line break.

Features:

  • Inline container element
  • Text content with optional styling
  • CSS styling support via CssStyle
  • Does not disrupt document flow

Usage:


 // Create span with text
 Span span = new Span("Hello");

 // Create span with styled text
 Span span = new Span("Important", "color: red; font-weight: bold");

 // Create span with CssStyle object
 CssStyle style = new CssStyle();
 style.setColor("blue");
 Span span = new Span("Styled", style);
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Span

      public Span()
      Constructs an empty <span> element.
    • Span

      public Span(String text)
      Constructs a <span> element with the specified text content.
      Parameters:
      text - the text content to display
    • Span

      public Span(String text, String style)
      Constructs a <span> element with text content and inline CSS.
      Parameters:
      text - the text content to display
      style - the inline CSS style string (e.g., "color: blue; font-size: 14px")
    • Span

      public Span(String text, CssStyle style)
      Constructs a <span> element with styled text content.
      Parameters:
      text - the text content to display
      style - the CSS style to apply