Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of svg:svg?

What is the meaning of this?

.append("svg:svg")

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

like image 286
user1365697 Avatar asked May 14 '12 12:05

user1365697


People also ask

What a SVG means?

Scalable Vector Graphics (SVG) are an XML-based markup language for describing two-dimensional based vector graphics.

What SVG is used for?

The SVG file format is a popular tool for displaying two-dimensional graphics, charts, and illustrations on websites. Plus, as a vector file, it can be scaled up or down without losing any of its resolution.

What is SVG explain with example?

Scalable Vector Graphics commonly known as SVG is a XML based format to draw vector images. It is used to draw two dimentional vector images. This tutorial will teach you basics of SVG. Tutorial contains chapters discussing all the basic components of SVG with suitable examples.

What does the SVG logo mean?

Everyone should use SVG format logos on their websites in 2020! SVG stands for “Scalable Vector Graphic,” an image format that allows an image to scale to almost any size without losing quality (and looks even better on retina displays). It is also a format that is a small file size and compresses well.


2 Answers

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

<html xmlns="http://www.w3.org/1999/xhtml">

you may specify the prefix as

<html xmlns:prefix="http://www.w3.org/1999/xhtml">

and then you'll use

<prefix:head>
    <prefix:title></prefix:title>
</prefix:head>

Similarily you can use

<svg xmlns="http://www.w3.org/2000/svg">

instead of just <svg> 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.

like image 68
Imp Avatar answered Oct 10 '22 13:10

Imp


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 <svg> element in an XHTML document has no meaning unless that SVG element is in the SVG namespace.

For more information, read Namespaces in XML.

like image 41
Phrogz Avatar answered Oct 10 '22 13:10

Phrogz