Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save benjaminblack/9a1f95aeb563687789f1d836368bcbf6 to your computer and use it in GitHub Desktop.
Save benjaminblack/9a1f95aeb563687789f1d836368bcbf6 to your computer and use it in GitHub Desktop.
Rules for XML prolog, DTD, and xmlns and version attributes in SVG

From two articles on stackoverflow and an MDN article:

In external SVG files (which should be served as image/svg+xml):

Include the prolog:

<?xml version="1.0" encoding="utf-8"?>

Include a DTD:

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

The xmlns attribute of the <svg> root element is required and the version attribute is recommended; the xmlns:xlink attribute is required only if the document uses xlink:

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

In internal SVG inlined in HTML5:

The prolog should not be included.

The DTD should not be included.

The version attribute is recommended, but is ignored by every user agent.

The xmlns, and xmlns:xlink attributes are not required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment