Which svg elements can be child, and which cant be

2019-05-07 09:14发布

In html we say, the inline elements should be within the block elements. Similiarly, is there any rule that i can use, to find out which svg elements can be child, and which cant be.

标签: svg
2条回答
萌系小妹纸
2楼-- · 2019-05-07 09:27

Containers that can contain graphics children are container elements:

[A container element] can have graphics elements and other container elements as child elements.

Specifically: ‘a’, ‘defs’, ‘glyph’, ‘g’, ‘marker’, ‘mask’, ‘missing-glyph’, ‘pattern’, ‘svg’, ‘switch’ and ‘symbol’.

Any element can have a non graphical child though e.g.

<rect>
   <title>what the rect is</title>
</rect>
查看更多
Lonely孤独者°
3楼-- · 2019-05-07 09:38

The specification contains a description of each each element, including which elements are allowed as children.

查看更多
登录 后发表回答