What is the meaning of svg:svg?

后端 未结 2 1196
轮回少年
轮回少年 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条回答
  •  猫巷女王i
    2021-02-01 18:29

    In XHTML code, one can use namespaces to distinguish other XML-based languages included in the webpage. Here, the namespace "svg" is used before the tag "svg".

    namespace:tagname
    

    This can be useful in case two tags (for example, in XHTML and SVG) have the same name and you want to exactly specify which one you refer to. The tags can be specified with the xmlns attribute. As you know, XHTML documents start with

    
    

    you may specify the prefix as

    
    

    and then you'll use

    
        
    
    

    Similarily you can use

    
    

    instead of just when including your svg graphic. Then all svg tags will start with the svgprefix prefix. However if you have child SVG nodes, they will also need this xmlns attribute to be defined. In such a case, defining the prefix will probably be easier.

提交回复
热议问题