W3C home > Mailing lists > Public > whatwg@whatwg.org > August 2010

[whatwg] Allow Select SVG Elements In <head>

From: Hugh Guiney <hugh.guiney@gmail.com>
Date: Fri, 27 Aug 2010 06:20:15 -0400
Message-ID: <AANLkTimBzaD=z7xx5OFodA=1iLUR+ayQEkeBhKmJb0LY@mail.gmail.com>
I'm authoring an XHTML host document with namespaced inline SVG and
XLink. I have vector images that recur throughout the site. I'd like
to implement SVG's <defs> and <use> to reduce the file size of the
document and keep style separate from content, as with CSS.

If I put an SVG tree with <defs> anywhere in the XHTML document, other
trees with <use xlink:href> will correctly reference it, as tested in
the latest public release Gecko, Webkit, and Opera. So the question
becomes, where do I put it? The most obvious answer seems to be
<head>, since, like CSS definitions, this is metadata being defined
for use elsewhere in the document. The only problem is, Validator.nu
doesn't like it:

"Error: SVG element svg not allowed as child of XHTML element head in
this context. (Suppressing further errors from this subtree.)"

Same error when ditching the root <svg> and including only <defs>, the
result of which still works in all but Opera.

This error can be avoided if the <defs> tree is put in the XHTML
<body>, but then there is blank space the size of the defined shapes
at the top of the document in all 3 engines. A workaround is to give
<svg> a @width and @height both of 0. But leaving the definitions in
the <body> when they technically don't represent contextual content
strikes me as non-semantic.

My proposition would be to simply spec a subset of SVG consisting only
of metadata elements as valid in HTML's <head> context. This could be
just <defs>?I'm unsure if there are any other elements that fit this
definition since I am relatively new to SVG; but in either case it'd
aid semantics and is already supported in today's SVG-capable
browsers.
Received on Friday, 27 August 2010 03:20:15 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:00 UTC