When using SVG within HTML5: Is the XML declaration needed with SVG
For HTML5, the correct DOCTYPE declaration is
It is needed to specify full standards mode to the browser.
What you've shown,
is an XML declaration. It is optional for XML 1.0 and required for XML 1.1, but
version="1.0" and encoding="utf-8" are the defaults anyway.Use an XML declaration in HTML5 when you wish to specify a different encoding, especially when the file might be consumed not just by browsers but also by XML processors.
For more information see HTML5: A vocabulary and associated APIs for HTML and XHTML.
Note regarding internal SVG (thanks, @Quentin): SVG embedded within an HTML5 document should not have an independent XML declaration. Only one XML declaration is allowed in well-formed XML, and it must be at the top, if anywhere. See this answer for further details regarding XML declaration placement requirements.
Note regarding external SVG (thanks, @Kaiido): SVG referenced via HTML5 img or CSS background-images must have its own XML declaration and should use the following DOCTYPE declaration:
Note regarding external SVG (update) (thanks, @user314159):
Per 1.3. SVG namespace and DTD of the Scalable Vector Graphics (SVG) 2 W3C Working Draft 09 July 2015:
A DTD is not provided in this specification, as the use of DTDs for validating documents is known to be problematic. In particular, DTDs do not handle namespaces gracefully and the range of constraints they can express is limited. It is recommended that authors do not include a DOCTYPE declaration in SVG documents.
[Emphasis added.]