Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting the SVG context properties when in an HTML <img> tag #348

Open
ExE-Boss opened this issue Oct 5, 2017 · 4 comments
Open

Comments

@ExE-Boss
Copy link

ExE-Boss commented Oct 5, 2017

Right now, there is no standard way to set the fill and stroke properties of an SVG inside an HTML <img> tag.

The SVG 2 specification has context properties (context-fill and context-stroke) that are set to the fill and stroke properties of the rendering context. The rendering context is currently only set when the SVG is imported into another SVG using the SVG <use> tag.

Mozilla Firefox currently has the non-standard vendor prefixed -moz-context-properties CSS property to do this, but other browsers don’t currently have any suitable equivalent.

For inter-operability with other browsers and to make it possible to control the fill and stroke SVG properties when the SVG is in an <img> tag, I request that something to do this be added to the specification.

@heycam
Copy link
Contributor

heycam commented Oct 6, 2017

Note that -moz-context-properties is an internal-only property and is not exposed to the Web. I agree it would be useful to have some mechanism for passing values down into a referenced SVG image — it's something we've been talking about for years! — and while the design of -moz-context-properties itself is maybe not great, it might be a starting point for another discussion.

@tabatkins
Copy link
Member

We don't currently expose any way for properties to inherit down into a separate document (which is what an img is).

But this use-case is what the SVG Parameters work was supposed to solve. It got dropped, unfortunately.

@AmeliaBR
Copy link
Contributor

We don't currently expose any way for properties to inherit down into a separate document (which is what an img is).

It's also what an SVG-in-OpenType font glyph is, but we've got multiple implementations using the context-* values to map CSS properties from the outer document to the inner document. I think it's very reasonable to extend that to any embedded image, where the context element is the element that embeds the document.

But we first need to figure out all the bugs about contexts and font glyphs.

(I'd also still like to see a more generic SVG Parameters feature, but we at least have implementations to build on with context-*. So I'd like to figure out how far we can go with them, and then assess whether there are still unmet use cases.)

@boggydigital boggydigital added this to the SVG 2.1 Working Draft milestone Jun 11, 2018
@boggydigital
Copy link
Contributor

Not blocking updated 2.0 CR publication - assigning 2.1 WD milestone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants