edit
You can load from an external document, as long as "that document comes from the same origin as the HTML document to which it's applied".
Make sure the html page that has the svg effect is being passed in the URL argument along with the ID of the svg effect (for instance,
So, instead of
url('#filter-effect')
do
filter: url('index.html#filter-effect')
It wasn't obvious to me how this worked until I read @RobertLongon's comment, but it makes sense now. You can put all your SVGs in a single document and reference them from other html files.
-
Old Answer:
Mozilla Developer Network says:
You may specify SVG in styles either within the same document, or within an external style sheet.
...but they're full of it. Bug report?
use <style>
instead of <link>
For reasons beyond my comprehension, if you declare the .blur
class outside the html document, via <link>
, your element will disappear while still occupying space. This is why the fiddles are working in other answers but implementation is not. JSFiddle appends your styles within the document using <style>
. To avoid this behavior, you should instead declare the .blur
class WITHIN the document, aka <style>...</style>
Also important:
NOTE: Namespacing is not valid in HTML5, leave off the "svg:" in tags for HTML-format documents.
Again, <style>
, not <link>
.
sources:
trial and error
mdn: Applying SVG effects to HTML content