Class SvgForeignObject<T extends SvgForeignObject<T>>


public class SvgForeignObject<T extends SvgForeignObject<T>> extends SvgContainerElement<T>
Represents an SVG <foreignObject> element.

The <foreignObject> element allows embedding non-SVG content (typically HTML) within an SVG document. Unlike other SVG containers that only accept SVG children, this element accepts any HTML element as a child.

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

    • SvgForeignObject

      public SvgForeignObject()
      Creates a new SVG foreignObject element.
  • Method Details

    • addElement

      public T addElement(Element child)
      Adds any HTML or SVG child element to this foreign object container.

      Unlike other SVG containers, <foreignObject> accepts non-SVG content such as HTML elements, allowing rich HTML markup to be embedded within SVG.

      Overrides:
      addElement in class Element<T extends SvgForeignObject<T>>
      Parameters:
      child - the element to add (HTML or SVG)
      Returns:
      this element for method chaining