<foreignObject>

Элемент <foreignObject> SVG позволяет включать другое пространство имён XML. В контексте браузера это, скорее всего, XHTML / HTML.

Пример

html
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
  <style>
    polygon {
      fill: black;
    }

    div {
      color: white;
      font: 18px serif;
      height: 100%;
      overflow: auto;
    }
  </style>

  <polygon points="5,5 195,10 185,185 10,195" />

  <!-- Типичный пример использования: встраивание HTML-текста в SVG -->
  <foreignObject x="20" y="20" width="160" height="160">
    <!--
В контексте SVG, внедрённого в HTML, пространство имён XHTML может и следует избегать,
но это обязательно в контексте документа SVG
   -->
    <div xmlns="http://www.w3.org/1999/xhtml">
      - Смолчал хозяин, да и то, что мог сказать - Мне невдомёк, но во владениях
      чертога Поможет дом срубить да судьбы вам связать. Не веришь ежли -
      испроси у Бога...
    </div>
  </foreignObject>
</svg>

Атрибуты

height (en-US)

Этот атрибут определяет высоту прямоугольника. Value type: <length>|<percentage> ; Default value: auto; Animatable: yes

width

Этот атрибут определяет ширину прямоугольника. Value type: <length>|<percentage> ; Default value: auto; Animatable: yes

x

Этот атрибут определяет координату x контейнера svg. Это не влияет на внешние элементы SVG. Value type: <length>|<percentage> ; Default value: 0; Animatable: yes

y

Этот атрибут определяет координату Y контейнера SVG. Это не влияет на внешние элементы SVG. Value type: <length>|<percentage> ; Default value: 0; Animatable: yes

Примечание: Starting with SVG2 x, y, width, and height are Geometry Properties, meaning those attributes can also be used as CSS properties for that element.

Глобальные атрибуты

Core Attributes

Most notably: id, tabindex (en-US)

Styling Attributes
class, style (en-US)
Conditional Processing Attributes

Most notably: requiredExtensions, systemLanguage (en-US)

Event Attributes

Global event attributes, Graphical event attributes, Document event attributes, Document element event attributes

Presentation Attributes

Most notably: clip-path (en-US), clip-rule (en-US), color (en-US), color-interpolation (en-US), color-rendering, cursor (en-US), display (en-US), fill, fill-opacity, fill-rule, filter (en-US), mask (en-US), opacity (en-US), pointer-events (en-US), shape-rendering, stroke, stroke-dasharray (en-US), stroke-dashoffset, stroke-linecap, stroke-linejoin (en-US), stroke-miterlimit (en-US), stroke-opacity (en-US), stroke-width, transform, vector-effect (en-US), visibility (en-US)

Aria Attributes

aria-activedescendant, aria-atomic, aria-autocomplete, aria-busy, aria-checked, aria-colcount, aria-colindex, aria-colspan, aria-controls, aria-current, aria-describedby, aria-details, aria-disabled, aria-dropeffect, aria-errormessage, aria-expanded, aria-flowto, aria-grabbed, aria-haspopup, aria-hidden, aria-invalid, aria-keyshortcuts, aria-label, aria-labelledby, aria-level, aria-live, aria-modal, aria-multiline, aria-multiselectable, aria-orientation, aria-owns, aria-placeholder, aria-posinset, aria-pressed, aria-readonly, aria-relevant, aria-required, aria-roledescription, aria-rowcount, aria-rowindex, aria-rowspan, aria-selected, aria-setsize, aria-sort, aria-valuemax, aria-valuemin, aria-valuenow, aria-valuetext, role

Примечания по использованию

КатегорииНет
Разрешённый контентЛюбые элементы и символы

Характеристики

Specification
Scalable Vector Graphics (SVG) 2
# ForeignObjectElement

Совместимость с браузерами

BCD tables only load in the browser