What is the meaning of svg:svg?

后端 未结 2 1191
轮回少年
轮回少年 2021-02-01 18:02

What is the meaning of this?

.append(\"svg:svg\")

I saw it in HTML and in D3 code. Does it add plugin of SVG?

2条回答
  •  伪装坚强ぢ
    2021-02-01 18:43

    From the documentation for D3.js's append() method:

    The element's tag name may have a namespace prefix, such as "svg:text" to create a "text" element in the SVG namespace. By default, D3 supports svg, xhtml, xlink, xml and xmlns namespaces. Additional namespaces can be registered by adding to d3.ns.prefix.

    Note in particular that the namespace prefixes in D3.js are not based on your document, but a predefined map of common prefixes to the actual namespace URL.

    Namespaces are the way an XML document (which includes XHTML but not HTML) can include two attributes or elements with the same name (e.g. "sin" as in mathematical sine calculation vs. "sin" as in moral failing) without conflict. Putting an element in an XHTML document has no meaning unless that SVG element is in the SVG namespace.

    For more information, read Namespaces in XML.

提交回复
热议问题