Re: [csswg-drafts] Support for passing CSS styles to an SVG used via img[src] (#8634)

@SebastianZ Thanks! I hadn't heard of that yet.

Some key differences between the two proposals areā€¦
* This proposal allows you to directly style such image sources (e.g. svg) in your usual CSS stylesheets rather than needing to declare such styles on the image source itself whether in `img[src]` or in the CSS `url()` function.
* This proposal allows you to work with the cascade and add any styles you want dynamically based on both the context the `img` element is in as well as the structure of the `svg` source itself (see example 5 above).
* (possibly most vital of all) The CSS Linked Parameters draft requires the SVG itself to accept and utilize these parameters directly, meaning that the SVG and the CSS using it are somewhat coupled.
  
Don't get me wrong, that draft looks rad, and I definitely could have benefitted from it on a handful of projects of my own over the years. However, the real value in this proposal is the ability to directly manipulate any SVG you pull in, which will often be the case for more custom modifications.
  
I certainly see icon libraries adopting the features outlined in the CSS Linked Parameters draft, though there are certainly bound to be instances where you want to style/manipulate an SVG in a way that the SVG author did not foresee. In cases like these, something like `::src` would be really useful for adding any desired custom styling to any SVG you have.

I think both this proposal and the CSS Linked Parameters spec would be super useful to the community at large, and that they may often be used together. For common, native resources like SVGs housed in your codebase and even some 3rd-party libs, CSS Linked Parameters would be very useful and provide a more uniform and controlled method for styling SVGs dynamically. For other cases where you want to style an SVG but don't want to host it in your codebase and where the author isn't adding CSS Linked Parameters-support, `::src` provides an instant solution and alternative to downloading the resource, adding it to your codebase and adding your own CSS Linked Parameters support to it.

-- 
GitHub Notification of comment by brandonmcconnell
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8634#issuecomment-1480263980 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 22 March 2023 21:10:18 UTC