+ 8

Are SVG elements considered HTML elements?

I ask this because I'm confused, are elements such as <circle>, <path>, <g>, <linearGradient, <animate>, etc not a part of HTML? I looked online in a list of all HTML elements and its true I didn't find any of the SVG elements, but I always thought they were a part of HTML, if they are not, then what are they?

30th Jul 2020, 8:04 PM
Karak10
Karak10 - avatar
3 ответов
+ 9
Good question. XHTML and SVG are both so-called "applications" of XML. XML is like a mother-language and XHTML and SVG are like dialects. I say XHTML because HTML technically isn't an XML application but we can ignore that detail. In the beginning of an XML document you will see what dialect of XML is being used, which tells you which tags are allowed. Here's the XHTML doctype definition, line 1 of every file: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> of course in HTML we shorten that to `<!DOCTYPE html>`. Same thing. For .svg files we have a similar `<!DOCTYPE svg ...>`. SVG has special status in HTML, HTML defines an `<svg>` tag in which you can put SVG code which is why we don't need a second <!doctype> in this case. But all the actual graphics tags are defined in the SVG standard. tl;dr they are two seperate languages with features for using one inside the other. (you can embed HTML inside SVG too with <foreignObject>. Pretty nutty.)
30th Jul 2020, 10:15 PM
Schindlabua
Schindlabua - avatar
+ 3
SVG i.e SCALABLE VECTOR GRAPHICS, drawings and images are created using a wide array of elements which are dedicated to the construction, drawing, and layout of vector images and diagrams. The elements you pointed above are basically dedicated to that task of coming up with SVGs and I guess that means they can't be called HTML elements
30th Jul 2020, 8:28 PM
ME_GUY_COROVITA
ME_GUY_COROVITA - avatar