-
Notifications
You must be signed in to change notification settings - Fork 131
/
linking.html
1197 lines (1036 loc) · 53.9 KB
/
linking.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional+edit//EN" "xhtml1-transitional+edit.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:edit="http://xmlns.grorg.org/SVGT12NG/">
<head>
<title>Linking</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<link rel="stylesheet" title="Default" type="text/css" media="screen" href="style/default_svg.css"/>
<link rel="alternate stylesheet" title="No issues/annotations" type="text/css" media="screen" href="style/default_no_issues.css"/>
<!--
<link rel="alternate stylesheet" title="CSS3 Unmodified" type="text/css" media="screen" href="style/default.css"/>
<link rel="alternate stylesheet" title="SVG 1.1" type="text/css" media="screen" href="style/svg-style.css"/>
-->
<!-- W3C style sheet will be added here during processing. -->
</head>
<body>
<h1>Linking</h1>
<div class="ready-for-WG-review">
<h2 id="URLReference">References</h2>
<h3 id="HeadOverview">Overview</h3>
<p>On the Internet, resources are identified using <a>URLs</a>
(Internationalized Resource Identifiers). For
example, an SVG file called someDrawing.svg located at
http://example.com might have the following <a>URL</a>:</p>
<pre>
http://example.com/someDrawing.svg
</pre>
<p>An <a>URL</a> can also address a particular element within an XML
document by including an <a>URL</a> fragment
identifier as part of the <a>URL</a>. An <a>URL</a> which includes an
<a>URL</a> fragment identifier consists of an optional base <a>URL</a>, followed by a "#" character,
followed by the <a>URL</a> fragment identifier. For example, the
following <a>URL</a> can be used to specify the element whose ID is
"Lamppost" within file someDrawing.svg:</p>
<pre>
http://example.com/someDrawing.svg#Lamppost
</pre>
<!-- from 1.2T - add this too?
<h4 id="AlteringHref">Altering the <span class="attr-name">'href'</span> attribute</h4>
<p>If the <a href="https://svgwg.org/specs/animations/#HrefAttribute"><span class="attr-name">'href'</span></a>
attribute of an element in the tree is altered by any means (e.g. script, declarative
animation) such that a new resource is referenced, the new resource must replace
the existing resource, and must be rendered as appropriate. For specific effects
on the scripting context when a <a>'script'</a> element's
<a>'script/href'</a> attribute is altered, see
<a href="interact.html#ScriptContentProcessing">Script processing</a>.</p>
-->
<h3 id="definitions">Definitions</h3>
<dl class='definitions'>
<dt><dfn id="TermURLReference" data-dfn-type="dfn" data-export="">URL reference</dfn></dt>
<dd>An URL reference is an Internationalized Resource Identifier, as defined in
<a href="http://www.ietf.org/rfc/rfc3987.txt"><cite>Internationalized Resource Identifiers</cite></a>
[<a href='refs.html#ref-rfc3987'>rfc3987</a>]. See
<a href="linking.html#URLReference">References</a> and
<a href="struct.html#Head">References and the
<span class="element-name">'defs'</span> element</a>.</dd>
<dt><dfn id="TermURLReferenceWithFragmentIdentifier" data-dfn-type="dfn" data-export="">URL reference with fragment identifier</dfn></dt>
<dd>An Internationalized Resource Identifier [<a href="refs.html#ref-rfc3987">rfc3987</a>] that
can include an <absoluteURL> or
<relativeURL> and a identifier of the fragment in that resource. See <a href="struct.html#Head">References and the
<span class="element-name">'defs'</span> element</a>. URL reference with fragment identifiers are commonly used to reference <a href="pservers.html">paint servers</a>.</dd>
<dt><dfn id="TermExternalReference" data-dfn-type="dfn" data-export="">external file reference</dfn></dt>
<dd>A <a>URL reference</a> or <a>URL reference with fragment identifier</a>
which refers to a resource that is not part of the current document.
</dd>
<dt><dfn id="TermSameDocumentURL" data-dfn-type="dfn" data-export="">same-document URL reference</dfn></dt>
<dd>A <a>URL reference with fragment identifier</a>
where the non-fragment part of the URL refers to the current document.
</dd>
<dt><dfn id="TermDataURL" data-dfn-type="dfn" data-export="">data URL</dfn></dt>
<dd>A <a>URL reference</a> to an embedded document
specified using the <a href="http://www.ietf.org/rfc/rfc2397.txt">"data" URL scheme</a>
[<a href="refs.html#ref-rfc2397">rfc2397</a>].
Data URL references are neither
<a>external file references</a> nor <a>same-document URL references</a>.
</dd>
<dt><dfn id="TermCircularReference" data-dfn-type="dfn" data-export="">circular reference</dfn></dt>
<dd><a href="#TermURLReference">URL references</a> that directly or indirectly reference
themselves are treated as invalid circular references.
What constitutes a circular reference will depend on how the referenced resource is used,
and may include a reference to an ancestor of the current element.
</dd>
<dt><dfn id="TermUnresolvedReference" data-dfn-type="dfn" data-export="">unresolved reference</dfn></dt>
<dd>A reference that is still being processed,
and has not yet resulted in either an error or an identified resource.
</dd>
<dt><dfn id="TermInvalidReference" data-dfn-type="dfn" data-export="">invalid reference</dfn></dt>
<dd>
<p>Any of the following are invalid references:</p>
<ul>
<li>A circular reference.</li>
<li>
A <a href="#TermURLReference">URL reference</a> that results in an error
during <a href="#processingURL">processing</a>.
</li>
<li>
A <a href="#TermURLReference">URL reference</a> that cannot be resolved.
</li>
<li>
A <a href="#TermURLReference">URL references</a> to elements which are
inappropriate targets for the given reference shall be treated as invalid
references
(see <a href="#processingURL-validity">Valid URL targets</a>
for appropriate targets).
For example, the <a>'clip-path'</a> property can only refer to
<a>'clipPath'</a> elements. The property setting
<span class="attr-value">clip-path:url(#MyElement)</span> is an
invalid reference if the referenced element is not a <a>'clipPath'</a>.</li>
</ul>
<p>Invalid references may or may not be an error
(see <a href="implnote.html#ErrorProcessing">Error processing</a>),
depending on whether the referencing property or attribute defines fallback behavior.
</p>
</dd>
</dl>
<h3 id="URLandURI">URLs and URIs</h3>
<p>Internationalized Resource Identifiers (<a>URLs</a>) are a more generalized
complement to Uniform Resource Identifiers (URIs). An <a>URL</a> is a sequence
of characters from the Universal Character Set [<a href="refs.html#ref-unicode">UNICODE</a>].
A URI is constructed from a much more restricted set of characters. All URIs are
already conformant <a>URLs</a>. A mapping from <a>URLs</a> to URIs is defined by
the <a>URL</a> specification, which means that URLs can be used instead of URIs
in XML documents, to identify resources. <a>URLs</a> can be converted to URIs
for resolution on a network, if the protocol does not support <a>URLs</a>
directly.</p>
<p>Previous versions of SVG, following XLink, defined an URL reference type
as a URI <em>or as a sequence of characters which must result in an URL after a
particular escaping procedure was applied</em>. The escaping procedure was repeated in the
XLink 1.0 specification [<a href="refs.html#ref-xlink">xlink</a>], and in the
W3C XML Schema Part 2: Datatypes specification [<a href="refs.html#ref-xmlschema-2">xmlschema-2</a>].
This copying introduced the possibility of error and divergence, but was done
because the <a>URL</a> specification was not yet standardized.</p>
<p>In this specification, the correct term <a>URL</a> is used for this "URI or sequence of characters
plus an algorithm" and the escaping method, which turns URLs into URIs, is defined by reference to the
<a href="http://www.ietf.org/rfc/rfc3987.txt">URL specification</a> [<a href="refs.html#ref-rfc3987">rfc3987</a>],
which has since become an IETF Proposed Standard. Other W3C specifications are
expected to be revised over time to remove these duplicate descriptions of the
escaping procedure and to refer to <a>URL</a> directly.</p>
<h3 id="URLforms">Syntactic forms: URL and <url></h3>
<p>In SVG, most structural relationships between two elements
are specified using a URL value in an <a href="#linkRefAttrs"><span
class="attr-name">'href'</span></a> attribute.
However, many <a>presentation attributes</a> allow both URLs and text strings as content.
To disambiguate a text string from a relative URL, the <a><url></a>
production is used for presentation attributes,
and their corresponding CSS properties [<a href="refs.html#ref-css-values">css-values</a>].
This is simply a URL delimited with a functional notation.
</p>
<p>SVG makes extensive use of <a>URL</a> references, both absolute and relative,
to other objects.
For example, a <a>'linearGradient'</a> element
may be based on another gradient element,
so that only the differences between the two need to be specified,
by referencing the source gradient with a URL in the <a>'href'</a> attribute:
</p>
<edit:example href="images/linking/05_07.xml" image="no" link="no"/>
<p>
To fill a rectangle with that gradient,
the value of the rectangle's <a>'fill'</a> property may be set so as to
include a URL reference to the relevant <a>'linearGradient'</a> element;
here is an example:
</p>
<edit:example href="images/linking/05_08.xml" image="no" link="no"/>
<!-- old stuff from 1.1 for checking
<p id="URLReference">URL references are defined in either of the
following forms:</p>
<pre class='grammar'><![CDATA[
<URL-reference> = [ <absoluteURL> | <relativeURL> ] [ "#" <elementID> ] -or-
<URL-reference> = [ <absoluteURL> | <relativeURL> ] [ "#xpointer(id(" <elementID> "))" ]
]]></pre>
<p>where <span class="grammar"><elementID></span>
is the ID of the referenced element.</p>
<p>(Note that the two forms above (i.e.,
<span class="attr-value">#<elementID></span> and
<span class="attr-value">#xpointer(id(<elementID>))</span>)
are formulated in syntaxes compatible with "XML Pointer Language (XPointer)"
[<a href="https://www.w3.org/TR/xptr">XPTR</a>]. These two formulations of URL
references are the only XPointer formulations that are required in SVG 1.1 user
agents.)</p>
-->
<h3 id="linkRefAttrs">URL reference attributes</h3>
<p id="linkRefAttrsEmbed"><a>URL references</a> are normally specified with an
<span class="attr-name">'href'</span> attribute.
The value of this attribute forms a reference for the desired resource (or
secondary resource, if there is a fragment identifier).
The value of the <span class="attr-name">'href'</span>
attribute must be a URL.</p>
<p>Because it is impractical for any application to check that
a value is an <a>URL reference</a>, this specification follows the lead
of the <a href="http://www.ietf.org/rfc/rfc3986.txt">URL Specification</a>
in this matter and imposes no such conformance testing
requirement on <a>SVG authoring tools</a>.
An invalid URL does not make an SVG document non-conforming.
SVG user agents are only required to process URLs when needed,
as specified in <a href="#processingURL">Processing of URL references</a>.
</p>
<h3 id="XLinkRefAttrs">Deprecated XLink URL reference attributes</h3>
<p>In previous versions of SVG, the <span class="attr-name">'href'</span>
attribute was specified in the XLink namespace [<a
href="refs.html#ref-xlink">xlink</a>] namespace.
This usage is now deprecated and instead <a>URL references</a> should be
specified using the <span class="attr-name">'href'</span> attribute without
a namespace.</p>
<p>For backwards compatibility, the deprecated <a>'xlink:href'</a> attribute
is defined below along with the <a>'xlink:title'</a> attribute which has also
been deprecated.</p>
<p><em>Attribute definitions:</em></p>
<dl class="attrdef-list">
<dt>
<table class="attrdef def">
<tr>
<th>Name</th>
<th>Value</th>
<th>Initial value</th>
<th>Animatable</th>
</tr>
<tr>
<td><dfn id="XLinkHrefAttribute" data-dfn-type="element-attr" data-dfn-for="a, image, linearGradient, pattern, radialGradient, script, textPath, use" data-export="">xlink:href</dfn></td>
<td>URL <a href="types.html#attribute-url" class="syntax">[URL]</a></td>
<td>(none)</td>
<td>(see below)</td>
</tr>
</table>
</dt>
<dd>
<p>For backwards compatibility, elements with an <span
class="attr-name">'href'</span> attribute also recognize an <span
class="attr-name">'href'</span> attribute in the XLink namespace [<a
href="refs.html#ref-xlink">xlink</a>].</p>
<p>When the <span class="attr-name">'href'</span> attribute is present in
<em>both</em> the XLink namespace and without a namespace, the
value of the attribute without a namespace shall be used. The attribute in
the XLink namespace shall be ignored.</p>
<p>A <a>conforming SVG generator</a> must generate <span
class="attr-name">'href'</span> attributes without a namespace.
However, it may <em>also</em> generate <span class="attr-name">'href'</span>
attributes in the XLink namespace to provide backwards compatibility.</p>
<p>This attribute is <a>animatable</a> if and only if the corresponding
<span class="attr-name">'href'</span> attribute is defined to be
animatable.</p>
</dd>
<dt>
<table class="attrdef def">
<tr>
<th>Name</th>
<th>Value</th>
<th>Initial value</th>
<th>Animatable</th>
</tr>
<tr>
<td><dfn id="XLinkTitleAttribute" data-dfn-type="element-attr" data-dfn-for="a, image, linearGradient, pattern, radialGradient, script, textPath, use" data-export="">xlink:title</dfn></td>
<td><anything></td>
<td>(none)</td>
<td>no</td>
</tr>
</table>
</dt>
<dd>
<p>Deprecated attribute to describe the meaning of
a link or resource in a human-readable fashion.
New content should use a <a href="struct.html#TitleElement"><span
class="element-name">'title'</span></a> child element rather than a <span
class="attr-name">'xlink:title'</span> attribute.</p>
<p>The use of this information is highly dependent on the type of processing
being done. It may be used, for example, to make titles
available to applications used by visually impaired users,
or to create a table of links, or to present help text that
appears when a user lets a mouse pointer hover over a
starting resource.</p>
<p>The <span class="attr-name">'title'</span> attribute, if used, must be
in the XLink namespace.
Refer to the <a href="https://www.w3.org/TR/xlink/">XML Linking Language
(XLink)</a> [<a href="refs.html#ref-xlink">xlink</a>].</p>
</dd>
</dl>
<p>When using the deprecated XLink attributes <a>'xlink:href'</a> or
<a>'xlink:title'</a> an explicit XLink namespace declaration must be provided
[<a href="refs.html#ref-xml-names">xml-names</a>],
One simple way to provide such an XLink namespace declaration
is to include an <span class="attr-name">'xmlns'</span> attribute
for the XLink namespace on the <a>'svg'</a> element for content that uses
XLink attributes. For example:</p>
<pre class='xml'><![CDATA[
<svg xmlns:xlink="http://www.w3.org/1999/xlink" ...>
<image xlink:href="foo.png" .../>
</svg>
]]></pre>
<h3 id="processingURL">Processing of URL references</h3>
<p>
URLs are processed to identify a resource at the time they are needed, as follows:
</p>
<ul>
<li>For the <a>'a/href'</a> attribute of the <a>'a'</a> element,
at the time the link is activated by the user.
</li>
<li>For all other <a>'href'</a> attributes,
at the time the element is <a href="https://dom.spec.whatwg.org/#connected">connected</a> to a document,
or at the time when the attribute is set, whichever is later.
</li>
<li>For source URLs on embedded HTML media elements,
as required based on source selection rules
<a href="https://www.w3.org/TR/html51/semantics-embedded-content.html#the-media-elements">in the HTML specification</a> [<a href="refs.html#ref-html51">HTML</a>].
</li>
<li>For all presentation attributes and style properties,
at the time the property is required for rendering an element.
</li>
</ul>
<p>
Legacy <a>'xlink:href'</a> attributes are processed
at the time a corresponding <a>'href'</a> attribute would be processed,
but only if no such <a>'href'</a> attribute exists on the element.
</p>
<p>Processing a URL involves three steps:
generating the absolute URL;
fetching the document (if required);
identifying the target element (if required).
</p>
<p>
A URL reference is <a>unresolved</a>
until processing either results in an <a>invalid reference</a>
or in the identification of the target resource.
Unresolved references in the non-presentation attributes of
<a>structurally external elements</a> prevent the <a href="interact.html#LoadEvent">load event</a>
from firing. User agents may place time limits on the resolution of references
that are not <a>same-document URL references</a>,
after which the reference is treated as a network error
(and therefore as an <a>invalid reference</a>).
</p>
<p>
For <a>same-document URL references</a> in a dynamic document,
modifications or animations of attributes or properties,
or removal of elements from the DOM,
may cause an URL reference to return to the <a>unresolved</a> state.
The user agent must once again attempt to resolve the URI to identify the referenced resource.
</p>
<h4 id="processingURL-absolute">Generating the absolute URL</h4>
<p>If the <a>URL reference</a> is relative, its absolute version must be computed before use.
The absolute URL should be generated using one of the following methods:
</p>
<ul>
<li>
as described in <a href="https://drafts.csswg.org/css-values/#local-urls">CSS Values and Units</a> if the reference occurs in a CSS file or in a <a>presentation attribute</a>
[<a href="refs.html#ref-css-values">css-values</a>]
</li>
<li>
as described in <a href="https://www.w3.org/TR/xmlbase/">XML Base</a> before use [<a href="refs.html#ref-xmlbase">xmlbase</a>]
if the reference occurs in any other attribute in an XML document
</li>
<li>
as described in the <a href="https://www.w3.org/TR/html51/infrastructure.html#parsing-urls">HTML specification</a>
if the reference occurs in a non-presentation attribute
in an HTML document that is not an XML document [<a href="refs.html#ref-html51">HTML</a>]
</li>
</ul>
<p class="note">
The <a href="https://www.w3.org/TR/xmlbase/#syntax"><span class="attr-name">'xml:base'</span></a> attribute
will only have an effect in XML documents;
this includes SVG documents and XHTML documents but not HTML documents that are not XML.
In contrast, a <a class="html" href="https://www.w3.org/TR/html/document-metadata.html#the-base-element"><code>base</code></a> element
affects relative URLs in any SVG or HTML document,
by altering the <a href="https://www.w3.org/TR/html51/infrastructure.html#document-base-url">document base URL</a>.
</p>
<p>If the protocol, such as HTTP, does not support <a>URLs</a> directly,
the <a>URL</a> must be converted to a URI by the user agent, as described
in section 3.1 of the <a href="http://www.ietf.org/rfc/rfc3987.txt">URL specification</a> [<a href="refs.html#ref-rfc3987">rfc3987</a>].</p>
<p>After generating the absolute URL:</p>
<ul>
<li>
<p>
If the URL is being processed following the activation of a link,
the user agent must follow the <a href="https://www.w3.org/TR/html51/browsers.html#browsing-the-web">algorithm for navigating to a URL</a>
described in the HTML specification [<a href="refs.html#ref-html51">HTML</a>].
The outcome of this algorithm varies depending on the
<a>'a/target'</a> browsing context and security restrictions between browsing contexts,
and on whether the link is to the same document as is currently contained in that browsing context
(in which case the fragment is navigated without reloading the document).
If the document that was navigated was an SVG document,
then adjust the target behavior as described in
<a href="#LinksIntoSVG">Linking into SVG content</a>.
</p>
</li>
<li>
<p>
If the URL being processed is only <a href="#processingURL-validity">valid</a>
if it refers to a complete document file
(such as the <a>'href'</a> attribute of
an <a>'image'</a> and <a>'script'</a> element),
continue as indicated in <a href="#processingURL-fetch">Fetching the document</a>
(regardless of whether the URL is to the same document or not).
</p>
</li>
<li>
<p>
In all other cases, the URL is for a resource to be used in this SVG document.
The user agent must parse the URL to separate out the target fragment from the rest of the URL,
and compare it with the document base URL.
If all parts other than the target fragment are equal,
this is a <a>same-document URL reference</a>,
and processing the URL must continue
as indicated in <a href="#processingURL-target">Identifying the target element</a>
with the current document as the referenced document.
</p>
</li>
<li>
<p>
Otherwise, the URL references a separate document,
and the user agent must continue processing the URL
as indicated in <a href="#processingURL-fetch">Fetching the document</a>.
</p>
</li>
</ul>
<p class="note">
As defined in <a href="https://drafts.csswg.org/css-values/#local-urls">CSS Values and Units</a>,
a fragment-only URL in a style property must be treated as
a <a>same-document URL reference</a>,
regardless of the file in which the property was declared.
</p>
<h4 id="processingURL-fetch">Fetching the document</h4>
<p>
SVG properties and attributes may reference other documents.
When processing such a URL,
the user agent should fetch the referenced document
as described in this section,
except under the following conditions:
</p>
<ul>
<li>
<p>
If the URL reference is from
the <span class="attr-name">href</span> attribute on <a href="https://svgwg.org/specs/animations/#TargetElement">SVG animation elements</a>,
only <a>same-document URL</a> references are allowed
[<a href="refs.html#ref-svg-animation">svg-animation</a>].
A URL referring to a different document is invalid
and the document must not be fetched.
</p>
</li>
<li>
<p>
If the document containing the reference is being processed in
<a>secure static mode</a> or <a>secure animated mode</a>,
<a>external file references</a> are disallowed.
Unless the reference is a <a>data URL</a>,
the user agent must treat the reference as if there was a network error,
making this an <a>invalid reference</a>.
</p>
</li>
<li>
<p>
If any other security restrictions
on the browsing context or user agent prevent accessing the external file,
then the user agent must treat the reference as if there was a network error.
</p>
</li>
</ul>
<p>
When fetching external resources from the Internet,
user agents must use a <a href="https://www.w3.org/TR/html51/infrastructure.html#creating-a-potential-cors-request">potentially CORS-enabled request</a>
as defined in HTML [<a href="refs.html#ref-html51">HTML</a>]
with the <em>corsAttributeState</em> as follows:
</p>
<ul>
<li>
For an <a>'href'</a> reference on an
<a>'image'</a> element or
<a>'script'</a> element,
the CORS state specified by the <a>'image/crossorigin'</a> attribute.
</li>
<li>
For a reference from a style property or presentation attribute,
the "anonymous" state.
</li>
<li>
For all other references,
the "no-cors" state.
</li>
</ul><a class="html" href="https://www.w3.org/TR/html/document-metadata.html#the-base-element"><code>base</code></a>
<p>
The request's <em>origin</em> is computed using the
<a href="https://fetch.spec.whatwg.org/#concept-cors-check" >same rules as HTML</a>,
with an SVG <a>'script'</a> element treated like an HTML <code>script</code> element,
and an SVG <a>'image'</a> element treated like an HTML <code>img</code> element.
The <em>default origin behaviour</em> must be set to <em>taint</em>.
</p>
<p class="note">
A future SVG specification may enable CORS references
on other SVG elements with <a>'href'</a> attributes.
</p>
<p>
If the fetching algorithm results in an error or an empty response body,
the reference URL is treated as an <a>invalid reference</a>.
</p>
<p>
If a valid response is returned,
and the <a href="#processingURL-validity">valid URL targets</a> for the reference
include specific element types,
the user agent must continue by
<a href="#processingURL-parsing">Processing the subresource document</a>.
Otherwise (if only entire-document the URL references are valid),
then the fetched document is the referenced resource.
</p>
<h4 id="processingURL-parsing">Processing the subresource document</h4>
<p>
Otherwise, the subresource must be parsed to identify the target element.
If the fetched document is a type that the user agent can parse
to create a document object model,
it must process it in <a>secure static mode</a>
(meaning, do not fetch any additional external resources
and do not run scripts or play animations or video).
The document model generated for an external subresource reference
must be immutable (read-only) and cannot be modified.
</p>
<p>
If a document object model can be generated from the fetched file,
processing the URL must continue
as indicated in <a href="#processingURL-target">Identifying the target element</a>
with the parsed subresource document as the referenced document.
The user agent may commence the target-identification process
prior to completely parsing the document.
</p>
<p>
User agents may maintain a list of external resource URLs
and their associated parsed documents,
and may re-use the documents for subsequent references,
so long as doing so does not violate the processing mode,
caching, and CORS requirements on the resource.
</p>
<h4 id="processingURL-target">Identifying the target element</h4>
<p>
For URL references to a specific element,
whether the reference is valid depends on whether
the element can be located within the referenced document
and whether it is of an allowed type.
</p>
<p>
Using the referenced document identified in previous processing steps
(either an external subresource document or the current document),
the target element is identified as follows:
</p>
<ul>
<li>
<p>
If the URL does not specify a specific element in a target fragment,
the target element is the root element of the referenced document.
</p>
</li>
<li>
<p>
Otherwise, the URL targets a specific element.
If a matching element currently exists in the referenced document,
then it is the target element.
</p>
</li>
<li>
<p>
Otherwise, there is no currently matching element.
If the referenced document is immutable,
then the URL reference is <a>invalid</a>.
An external subresource document is always immutable once fully parsed;
the current document is also immutable once parsed
if it is being processed in any mode other than
<a>dynamic interactive mode</a>.
</p>
</li>
<li>
<p>
Otherwise, observe mutations to the referenced document
until the URL can be successfully resolved
to define a target element,
or until the document becomes immutable
(e.g., a non-dynamic document finishes parsing).
</p>
</li>
</ul>
<p>The target element provides the referenced resource
if (and only if) it is a <a href="#processingURL-validity">valid URL target</a> for the reference.
</p>
<h4 id="processingURL-validity">Valid URL targets</h4>
<p>The valid target element types for <a>'href'</a> (or <a>'xlink:href'</a>) attributes are based on the element that has the attribute, as follows:</p>
<ul>
<li>the <a>'a'</a> element can reference any local or non-local resource</li>
<li>the <a>'image'</a> element must reference a document that can be processed as an image</li>
<li>the <a>'linearGradient'</a> element must reference a different <a>'linearGradient'</a> or <a>'radialGradient'</a> element</li>
<li>the <a>'pattern'</a> element must reference another <a>'pattern'</a> element</li>
<li>the <a>'radialGradient'</a> element must reference a <a>'linearGradient'</a> or another <a>'radialGradient'</a> element</li>
<li>the <a>'script'</a> element must reference an external document that provides the script content</li>
<li>the <a>'textPath'</a> element must reference an element type
that implements the <a>SVGGeometryElement</a> interface</li>
<li>the <a>'use'</a> element must reference either an SVG-namespaced element
or an HTML-namespaced element
<a href="embedded.html#HTMLElements">that may be included as a child of an SVG container element</a></li>
</ul>
<p>The valid target element types for style properties defined in this specification are as follows: </p>
<ul>
<!--
<li>the <a href="color.html#ColorProfileSrcProperty">'src'</a> descriptor on an @color-profile definition must reference an ICC profile resource</li>
-->
<li>the <a>'fill'</a> property (see <a href="painting.html#SpecifyingPaint">Specifying paint</a> for reference rules)</li>
<li>the <a>'marker property'</a>, <a>'marker-start'</a>, <a>'marker-mid'</a> and <a>'marker-end'</a> properties must reference a <a>'marker element'</a> element.</li>
<li>the <a>'shape-inside'</a> and <a>'shape-subtract'</a> properties must reference an element type
that implements the <a>SVGGeometryElement</a> interface,
or a document that can be processed as an image
</li>
<li>the <a>'stroke'</a> property (see <a href="painting.html#SpecifyingPaint">Specifying paint</a> for reference rules)</li>
</ul>
<p>
For references that allow either a reference to a target element, or to an image file
(such as the <a>'shape-inside'</a>, <a>'shape-subtract'</a>, and <a>'mask property'</a> properties),
the user agent must identify the target element and determine whether it is a valid target.
If the resolved target element is not an allowed element type,
the referenced resource is the entire document file;
the target fragment is used in processing that file as with any other image.
</p>
<p>In all other cases, if the resolved target element type (or document type) is not allowed for the URL reference,
it is an <a>invalid reference</a>.
</p>
</div>
<h2 id="Links">Links out of SVG content: the <span class="element-name">'a'</span> element</h2>
<edit:with element='a'>
<p>SVG provides an <a>'a'</a> element, to indicate links (also known
as <em>hyperlinks</em> or <em>Web links</em>).
An <a>'a'</a> element forms a link if it has a <a>'href'</a> or <a>'xlink:href'</a> attribute; without these attributes the <a>'a'</a> element is an inactive placeholder for a link.</p>
<p class="note">SVG 1.1 defined links in terms of the XLink specification ([<a href="https://www.w3.org/TR/2001/REC-xlink-20010627/">XLink</a>]),
using attributes defined in the XLink namespace.
SVG 2 uses an alternative set of attributes in the default namespace that are consistent with HTML links, and <a href="#XLinkRefAttrs">deprecates the XLink attributes</a>.</p>
<p>The <a>'a'</a> element may
contain any element that its parent may contain, except for another <a>'a'</a> element;
the same element is used for both graphical and textual linked content.
Links may not be nested;
if an <a>'a'</a> element is a descendent of another hyperlink element
(whether in the SVG namespace or another namespace),
user agents must ignore its href attribute and treat it as inactive.
The invalid <a>'a'</a> element must still be rendered as a generic container element.
</p>
<p class="issue" data-issue="18">The rendering of invalid nested links is at risk, and will likely be synchronized with any decisions regarding the rendering of <a>'unknown'</a> elements.</p>
<p>For pointer events processing,
a linked hit region is defined for each separate rendered element contained
within the <a>'a'</a> element (according to the value of their <a>'pointer-events'</a> property),
rather than for the bounding box of the <a>'a'</a> element itself.
User agents must also ensure that all links are <a>focusable</a> and can be activated by keyboard commands.</p>
<p>The remote resource (the destination for the link) is defined by
a <a>URL</a> specified by the <a>'href'</a> attribute on the <a>'a'</a>
element. The remote resource may be any Web resource (e.g., an image, a video
clip, a sound bite, a program, another SVG document, an HTML document, an
element within the current document, an element within a different document, etc.).
In response to user activation of a link
(by clicking with the mouse, through keyboard input, voice commands, etc.),
user agents should attempt to fetch the specified resource document and either display it or make it available as a downloaded file.</p>
<p id="ExampleLink01"><span class="example-ref">Example link01</span> assigns
a link to an ellipse.</p>
<edit:example href='images/linking/link01.svg' name='link01' description='a link on an ellipse' image='yes' link='yes'/>
<p>If the above SVG file is viewed by a user agent that supports both
SVG and HTML, then clicking on the ellipse will cause the current window
or frame to be replaced by the W3C home page.</p>
<div id="AElement">
<edit:elementsummary name='a'/>
</div>
<p><em>Attribute definitions:</em></p>
<dl class="attrdef-list">
<dt>
<table class="attrdef def">
<tr>
<th>Name</th>
<th>Value</th>
<th>Initial value</th>
<th>Animatable</th>
</tr>
<tr>
<td><dfn id="AElementHrefAttribute" data-dfn-type="element-attr" data-dfn-for="a" data-export="">href</dfn></td>
<td>URL <a href="types.html#attribute-url" class="syntax">[URL]</a></td>
<td>(none)</td>
<td>yes</td>
</tr>
</table>
</dt>
<dd>
The location of the referenced object, expressed as an <a>URL reference</a>.
Refer to the common handling defined for <a
href="linking.html#linkRefAttrs">URL reference attributes</a>.
</dd>
<dt>
<table class="attrdef def">
<tr>
<th>Name</th>
<th>Value</th>
<th>Initial value</th>
<th>Animatable</th>
</tr>
<tr>
<td><dfn id="AElementTargetAttribute" data-dfn-type="element-attr" data-dfn-for="a" data-export="">target</dfn></td>
<td> _self | _parent | _top | _blank | <XML-Name></td>
<td>_self</td>
<td>yes</td>
</tr>
</table>
</dt>
<dd>
<p>This attribute should be used when there are multiple possible targets for
the ending resource, such as when the parent document is embedded within an HTML
or XHTML document, or is viewed with a tabbed browser. This attribute specifies the
name of the browsing context
(e.g., a browser tab or an SVG, HTML, or XHTML iframe or object element) into
which a document is to be opened when the link is activated:</p>
<dl>
<dt><span class="attr-value">_self</span></dt>
<dd>The current SVG image is replaced by the linked content in the
same browsing context as the current SVG image.</dd>
<dt><span class="attr-value">_parent</span></dt>
<dd>The immediate parent browsing context of the SVG image is replaced by the
linked content, if it exists and can be securely accessed from this document.</dd>
<dt><span class="attr-value">_top</span></dt>
<dd>The content of the full active window or tab is replaced by the linked content,
if it exists and can be securely accessed from this document</dd>
<dt><span class="attr-value">_blank</span></dt>
<dd>A new un-named window or tab is requested for the display of the
linked content, if this document can securely do so.
If the user agent does not support multiple windows/tabs,
the result is the same as <span class="attr-value">_top</span>.</dd>
<dt><span class="attr-value"><XML-Name></span></dt>
<dd>Specifies the name of the browsing context (tab, inline frame, object, etc.)
for display of the linked content. If a context with this name
already exists, and can be securely accessed from this document, it is re-used,
replacing the existing content. If it does not exist, it is created
(the same as <span class="attr-value">'_blank'</span>, except that
it now has a name). The name must be a valid XML Name [XML11], and should not start
with an underscore (U+005F LOW LINE character), to meet the requirements of a
<a href="https://www.w3.org/TR/html51/browsers.html#valid-browsing-context-name">valid
browsing context name</a> from HTML.</dd>
</dl>
<p> The normative definitions for browsing contexts and security
restrictions on navigation actions between browsing contexts
is HTML [<a href="refs.html#ref-html51">HTML</a>], specifically
<a href="https://www.w3.org/TR/html51/browsers.html">the chapter on
loading web pages</a>.
</p>
<!--
The SVG 1.1 text for "_blank" was:
<dt><span class="attr-value">_blank</span></dt>
<dd>A new un-named window or tab is requested for the display of the
linked content. If this fails, the result is the same as <span class="attr-value">_top</span></dd>
However, under HTML a request for a new tab may fail
because of sandboxing/no-popups, in which case the link is simply not followed.
The new language reflects this restriction while still supporting the old
behavior in single-window SVG viewers (if such exist).
-->
<div class="note">
<p>Previous versions of SVG defined the special target value
<span class="attr-value">'_replace'</span>. It was never well implemented,
and the distinction between <span class="attr-value">'_replace'</span>
and <span class="attr-value">'_self'</span> has been made redundant by
changes in the HTML definition of browsing contexts. Use
<span class="attr-value">'_self'</span> to replace the current
SVG document.</p>
<p>The value <span class="attr-value">'_new'</span> is <em>not</em> a
legal value for target. Use <span class="attr-value">'_blank'</span>
to open a document in a new tab/window.</p>
</div>
</dd>
<dt>
<table class="attrdef def">
<tr>
<th>Name</th>
<th>Value</th>
<th>Initial value</th>
<th>Animatable</th>
</tr>
<tr>
<td><dfn id="AElementDownloadAttribute" data-dfn-type="element-attr" data-dfn-for="a" data-export="">download</dfn></td>
<td>any value (if non-empty, value represents a suggested file name)</td>
<td>(none)</td>
<td>no</td>
</tr>
<tr>
<td><dfn id="AElementPingAttribute" data-dfn-type="element-attr" data-dfn-for="a" data-export="">ping</dfn></td>
<td>space-separated valid non-empty URL tokens <a href="https://html.spec.whatwg.org/multipage/links.html#ping" class="syntax">[HTML]</a></td>
<td>(none)</td>
<td>no</td>
</tr>
<tr>
<td><dfn id="AElementRelAttribute" data-dfn-type="element-attr" data-dfn-for="a" data-export="">rel</dfn></td>
<td>space-separated keyword tokens <a href="https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#set-of-space-separated-tokens" class="syntax">[HTML]</a></td>
<td>(none)</td>
<td>no</td>
</tr>
<tr>
<td><dfn id="AElementHreflangAttribute" data-dfn-type="element-attr" data-dfn-for="a" data-export="">hreflang</dfn></td>
<td>A BCP 47 language tag string <a href="https://html.spec.whatwg.org/multipage/links.html#attr-hyperlink-hreflang" class="syntax">[HTML]</a></td>
<td>(none)</td>
<td>no</td>
</tr>
<tr>
<td><dfn id="AElementTypeAttribute" data-dfn-type="element-attr" data-dfn-for="a" data-export="">type</dfn></td>
<td>A MIME type string <a href="https://html.spec.whatwg.org/multipage/infrastructure.html#mime-type" class="syntax">[HTML]</a></td>
<td>(none)</td>
<td>no</td>
</tr>
<tr>
<td><dfn id="AElementReferrerpolicyAttribute" data-dfn-type="element-attr" data-dfn-for="a" data-export="">referrerPolicy</dfn></td>
<td>A referrer policy string <a href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy" class="syntax">[REFERRERPOLICY]</a></td>
<td>(none)</td>
<td>no</td>
</tr>
</table>
</dt>
<dd>
These attributes further describe the targetted resource
and its relationship to the current document.
Allowed values and meaning are <a href="https://www.w3.org/TR/html51/textlevel-semantics.html#the-a-element">as defined for the <code>a</code> element in HTML</a>.
</dd>
</dl>
</edit:with>
<h2 id="LinksIntoSVG">Linking into SVG content: URL fragments and SVG views</h2>
<p>Because SVG content often represents a picture or drawing
of something, a common need is to link into a particular
<em>view</em> of the document, where a view indicates
the initial transformations so as to present a closeup of a particular
section of the document.</p>
<div class="ready-for-wider-review">
<h3 id="SVGFragmentIdentifiers">SVG fragment identifiers</h3>
<div class="annotation svg2-requirement">
<table>
<tr>
<th>SVG 2 Requirement:</th>
<td>Merge the SVG 1.1 SE text and the SVG Tiny 1.2 text on fragment identifiers link traversal and add media fragments.</td>
</tr>
<tr>
<th>Resolution:</th>
<td><a href="http://www.w3.org/2012/03/08-svg-irc#T21-05-52">SVG 2 will have media fragment identifiers.</a></td>
</tr>
<tr>
<th>Purpose:</th>
<td>To align with Media Fragments URI.</td>
</tr>
<tr>
<th>Owner:</th>
<td>Cyril (<a href="http://www.w3.org/Graphics/SVG/WG/track/actions/3442">ACTION-3442</a>)</td>
</tr>
</table>
</div>
<p>To link into a particular view of an SVG document, the <a href="#TermURLReferenceWithFragmentIdentifier">URL reference with fragment
identifier</a> needs to be a correctly formed <dfn id='svg-fragment-identifier' data-dfn-type="dfn" data-export="">SVG
fragment identifier</dfn>. An SVG fragment identifier defines the
meaning of the "selector" or "fragment identifier" portion of URLs that
locate resources of MIME media type "image/svg+xml".</p>
<p>An SVG fragment identifier can come in the following forms:</p>
<ul>
<li>Shorthand <em>bare name</em> form of addressing (e.g.,
<span class="attr-value">MyDrawing.svg#MyView</span>). This form of
addressing, which allows addressing an SVG element by its ID, is compatible
with the fragment addressing mechanism for older versions of HTML.</li>
<li>An <dfn id="SVGViewSpecification" data-dfn-type="dfn" data-export="">SVG view specification</dfn>
(e.g., <span class="attr-value">MyDrawing.svg#svgView(viewBox(0,200,1000,1000))</span>).
This form of addressing specifies the desired view of the
document (e.g., the region of the document to view, the
initial zoom level) completely within the SVG fragment
specification. The contents of the SVG view specification are defined in
<a href="#SVGFragmentIdentifiersDefinitions">SVG fragment identifiers definitions</a> section.
</li>
<li id="MediaFragments"><em>Basic media fragments identifiers</em> of type spatial or temporal
(e.g., <span class="attr-value">MyDrawing.svg#xywh=0,200,1000,1000 or MyAnimation.svg#t=10)</span>)
as defined in [<a href="refs.html#ref-media-frags">Media Fragments URI 1.0 (basic)</a>] and possibly combined using the & sign (e.g. <span class="attr-value">MyDrawing.svg#xywh=0,200,1000,1000&t=10</span>).
</li>
</ul>
<h3 id="SVGFragmentIdentifiersDefinitions">SVG fragment identifiers definitions</h3>
<p>An SVG fragment identifier is defined as follows:</p>
<pre class='grammar'>
SVGFragmentIdentifier ::= BareName *( "&" <a href="https://www.w3.org/TR/media-frags/#timesegment">timesegment</a> ) |
SVGViewSpec *( "&" <a href="https://www.w3.org/TR/media-frags/#timesegment">timesegment</a> ) |
<a href="https://www.w3.org/TR/media-frags/#spacesegment">spacesegment</a> *( "&" timesegment ) |
<a href="https://www.w3.org/TR/media-frags/#timesegment">timesegment</a> *( "&" spacesegment )
BareName ::= XML_Name
SVGViewSpec ::= 'svgView(' SVGViewAttributes ')'
SVGViewAttributes ::= SVGViewAttribute |
SVGViewAttribute ';' SVGViewAttributes
SVGViewAttribute ::= viewBoxSpec |
preserveAspectRatioSpec |
transformSpec |
zoomAndPanSpec
viewBoxSpec ::= 'viewBox(' ViewBoxParams ')'
preserveAspectRatioSpec = 'preserveAspectRatio(' AspectParams ')'
transformSpec ::= 'transform(' TransformParams ')'
zoomAndPanSpec ::= 'zoomAndPan(' ZoomAndPanParams ')'