C
C
ClassicRed2014-01-04 22:08:01
Vector graphics
ClassicRed, 2014-01-04 22:08:01

Do I need to specify the doctype in the svg file (exactly in a separate file, not in the inlan tag)?

in fact, you read the question (probably), I optimize the svg image (remove unnecessary things, combine them into groups, etc.), I came across this example of svg code
who is too lazy to follow the link - the svg element has a baseProfile attribute - I have problems with English, but according to circumstantial evidence, this attribute can replace the doctype (checked the image without doctype with a validator - no errors). In terms of file optimization, this is a trifle, but I would just like to find out for myself and calm down:
Is it necessary to specify the doctype in the svg file?
PS version svg 1.1
PSS can just give a link - I can read

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alltiptop, 2014-05-04
@alltiptop

Of course, the full version will be valid, but all browsers and programs understand without metadata:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
    "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1"
     baseProfile="full"
     xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:ev="http://www.w3.org/2001/xml-events"
     width="100%" height="100%">
<rect fill="white" x="0" y="0" width="100%" height="100%" />
<rect fill="silver" x="0" y="0" width="100%" height="100%" rx="1em"/>
</svg>

It will be enough (not valid, but it works everywhere)
<svg version="1.1"
     xmlns="http://www.w3.org/2000/svg"
<!-- некоторые функции и фильтры работают только с указанием соответствующих стандартов, так что выкидывать всё подряд ни в коем случае не стоит -->
     width="100%" height="100%">
<rect fill="white" x="0" y="0" width="100%" height="100%" />
<rect fill="silver" x="0" y="0" width="100%" height="100%" rx="1em"/>
</svg>

Moreover, the latter option can be inserted directly into the html code .
For mass optimization, I advise SVG Cleaner , it cleans almost all garbage without complaints and losses.

A
alwas, 2015-01-20
@alwas

The SVG community, and in particular the developer Jonathan Watt , have come to the conclusion that in some cases when using Mozilla Firefox with a built-in SVG viewer, the content of the DOCTYPE declaration can be a source of errors. Therefore, they recommend against using the DOCTYPE declaration in SVG versions 1.0 and 1.1. Instead, it is recommended to include the baseProfile attribute on the root svg element with a value of “full”

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg version="1.1"
     baseProfile="full"
     xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:ev="http://www.w3.org/2001/xml-events"
     width="100%" height="100%">
<rect fill="white" x="0" y="0" width="100%" height="100%" />
<rect fill="silver" x="0" y="0" width="100%" height="100%" rx="1em"/>
</svg>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question