#247 [rst_html4css1] SVGs should be wrapped in <IMG> tag, not <OBJECT>


SVG wrapped in an <img> HTML tag is now supported across all browsers: http://caniuse.com/svg-img

The use of an <object> tag causes problems for some downstream users. Example: https://github.com/github/markup/issues/264

The diff for 'test/functional/expected/standalone_rst_html4css1.html' demonstrates the old and desired new behavior

Attached is a patch to revert to wrapping SVGs in <img> tags.

1 Attachments


  • Günter Milde

    Günter Milde - 2014-03-12

    The html4css1 writer is "optimized" for IE6.
    With current browsers, many of these workarounds are not required or stand in the way. This is why instead of using a tag not supported by IE6 with the HTML4transitional with CSS1 writer, I recommend applying this change to the "html4strict" writer (currently in the sandbox) and creating a new html4css2 writer based on html4strict.

  • Günter Milde

    Günter Milde - 2015-02-23

    The xhtml11 writer now (experimentally) uses "img" tags for SVG.

    However, while generally supported by "all" major browsers,
    rendering problems remain or new ones appear
    (have a look at test/functional/expected/standalone_rst_xhtml11.xhtml in various browsers): truncating instead of scaling, scaling of "fixed size" images in firefox, opera and chromium. No display of embedded bitmap images in Midori 0.4.3 (webkit).

    So we might need one more config setting.

    Last edit: Günter Milde 2015-03-12
  • Günter Milde

    Günter Milde - 2015-03-11

    As both wrappers (img and object) have pros and cons, there should be a cofiguration setting or an option argument :type:. This should also allow wrapping in SVG as a third option.

    See attached test file.

    Last edit: Günter Milde 2015-03-12
  • Cherniavsky Beni

    What does IE 6 has to do with this? IE 9 was the first to support SVG at all. Or are you considering IE 6 with some SVG viewer plugin?

    • Günter Milde

      Günter Milde - 2015-03-12

      Exactly. At the time of implementation, the "object" tag was the only means to have IE (and others) display SVG images (IE using one of several available plug-ins).

      The "html4css1" writer contains a number of hacks to accomodate the need of non-conforming browsers (namely IE6, the browser with the highest market share at the time this Docutils writer was coded).

      The new "xhtml11" and "html-base" writers produce clean and valid XHTML 1.1 rsp. HTML 5 for viewing with up-to-date norm-conforming browsers aided by a provided CSS2.1 stylesheet.

      These writers may benefit from a "svg-image-wrapper" option with support for "img", "object", and "svg". (Defaulting to "img")

  • Günter Milde

    Günter Milde - 2015-03-13
    • status: open --> closed-fixed
  • Günter Milde

    Günter Milde - 2015-03-13

    The "html-base" and "xhtml11" writers use tags for SVG now.
    The "html4css1" writer will not change the default.

    A command line option or directive option for the inclusion method would be a separate feature request.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks