0

Was svg support introduced in html5? That's what this url appears to indicate:

https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5

Svg 1.0 was established in 2001. Was there limited browser support or no browser support at all for svg until html5?

user9173787
  • 101
  • 1
  • 1
  • 3
  • 1
    You can checkout svg support in different browsers [here](https://caniuse.com/#search=svg) – Phonolog Jan 12 '18 at 15:45
  • 1
    HTML5 introduced the possibility to inline SVG elements directly into HTML markup. Before that, only X(HT)ML allowed to create such "mixed" documents. Also, [this page](https://www.w3.org/2010/09/svg_browser.php) seems to summarize the history of SVG support in browsers quite well. – Ilya Streltsyn Jan 12 '18 at 16:12

1 Answers1

2

As Ilya Streltsyn said,

HTML5 introduced the possibility to inline SVG elements directly into HTML markup. Before that, only X(HT)ML allowed to create such "mixed" documents.

This is due to SVG being an XML-based standard, like XHTML. You couldn't inline SVG markup directly into older versions of HTML, because older versions of HTML were SGML-based and therefore incompatible with XML-based SVG markup.

HTML5 throws all its SGML roots out the window in favor of just basing itself on its own syntax that's interoperable with SVG and MathML (another XML-based language) by design. This is what allows SVG to be inlined into HTML5 markup.

SVG as an image format is supported in Internet Explorer starting from version 9. As pointed out above, this page offers a good summary of browser support for SVG. The ability to inline SVG markup in HTML markup is available in browsers with HTML5 parsers, which includes IE starting from version 10.

BoltClock
  • 630,065
  • 150
  • 1,295
  • 1,284
  • Why would HTML < 5 not allow inline SVG due to SGML or due to SVG being based on XML? SGML is the superset of both HTML and XML, and allows undeclared elements. HTML, being based on SGML originally, has always parsed SVG and other non-HTML markup just as undeclared elements. Even today, HTML5 parses inline SVG under HTML (SGML NAMECASE GENERAL NO) rules eg. by ignoring uppercase/lowercase such that the SVG element `linearGradient` and `LINEARGRADIENT` or any other upper-/lowercase variant is treated just the same. – imhotap Jan 12 '18 at 21:59
  • @imhotap: You are correct on all counts. The fact that SVG is treated as unknown elements is probably the actual reason legacy parsers have been unable to render SVG markup in HTML. As for HTML5 parsing rules, yes, that's what I meant by being interoperable with SVG and MathML by design. – BoltClock Jan 13 '18 at 05:32
  • 1
    @imhotap - One of the biggest problems embedding SVG in HTML prior to HTML5 was what browsers should do with empty elements which. since SVG is an application of XML, can be written with self-closing syntax e.g. ``. In browsers before they had HTML5 parsers, that would be treated as a start tag, whereas, providing it appears inside an `` element, will be treated as self-closing by HTML5 parsers. – Alohci Jan 14 '18 at 01:10
  • @BoltClock - IE 10 was the first version of IE to have an HTML5 parser, not 9. – Alohci Jan 14 '18 at 01:26
  • @Alohci: My mistake (and [I was supposed to know this](https://stackoverflow.com/questions/9900311/how-do-i-target-only-internet-explorer-10-for-certain-situations-like-internet-e/9900331#9900331)) - looks like 9 simply introduced some [interop improvements](https://blogs.msdn.microsoft.com/ie/2010/09/13/interoperable-html-parsing-in-ie9) before completely changing the parser. – BoltClock Jan 14 '18 at 03:25