treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Right way to put SVG code directly into HTML?

  • As SVG tag is not recommended by W3C with what tag you should wrap SVG code in HTML? Though all modern browsers render it perfectly valid document is a right way to go. :)

  • If you're not using the svg element can you actually USE svg code?

    Anyway, from my reading every web browser supports SVG except Internet Explorer versions 8 and older.

  • There should be of course SVG element(don't know will it work without), i wished to ask with what element you should wrap SVG element. Like OBJECT...?

    Document didn't pass validation in Brackets with JSLint. Now I did validation in http://html5.validator.nu/ and he says "The document is valid HTML5 + ARIA + SVG 1.1 + MathML 2.0".

    All modern browsers do support it perfectly and i have no concerns for older browsers, they are pretty much dead for me. Well XP users on IE8 are only concern, but also i think that "right" users on XP use Chrome or Firefox.

    So i guess it's fine too use SVG element without OBJECT...

  • JSLint will reject all sorts of things that are fine...I wouldn't worry about it.