- href
- Example
- In SVG
- a
- animate, animateMotion, animateTransform, set
- feImage
- image
- linearGradient
- mpath
- pattern
- radialGradient
- script
- textPath
- use
- Specifications
- Browser compatibility
- See also
- Found a content problem with this page?
- Html и svg ссылка
- Атрибуты
- Глобальные атрибуты
- Интерфейс DOM
- Примечания к использованию
- Спецификации
- Совместимость с браузерами
- Found a content problem with this page?
- MDN
- Support
- Our communities
- Developers
- Html и svg ссылка
- Example
- Attributes
- Global attributes
- Usage notes
href
The href attribute defines a link to a resource as a reference URL. The exact meaning of that link depends on the context of each element using it.
Note: Specifications before SVG 2 defined an xlink:href attribute, which is now rendered obsolete by the href attribute. If you need to support earlier browser versions, the deprecated xlink:href attribute can be used as a fallback in addition to the href attribute, e.g. .
You can use this attribute with the following SVG elements:
Example
html, body, svg height: 100%; >
svg viewBox="0 0 160 40" xmlns="http://www.w3.org/2000/svg"> a href="https://developer.mozilla.org/"> text x="10" y="25">MDN Web Docstext> a> svg>
In SVG
a
Value | |
---|---|
Default value | None |
Animatable | Yes |
animate, animateMotion, animateTransform, set
The URL must point to exactly one target element which is capable of being the target of the given animation element. If the URL points to multiple target elements, if the given target element is not capable of being a target of the given animation element, or if the given target element is not part of the current document, then the animation element will not affect any target element. However, the animation element will still operate normally with regard to its timing properties. Specifically, TimeEvents are dispatched and the animation element can be used as syncbase in an identical fashion to when the URL refers to a valid target element.
If the href attribute or the deprecated xlink:href attribute is not provided, then the target element will be the immediate parent element of the current animation element. If both xlink:href and href are specified, the value of the latter attribute is used.
Refer to the descriptions of the individual animation elements for any restrictions on what types of elements can be targets of particular types of animations.
Except for any SVG-specific rules explicitly mentioned in this specification, the normative definition for this attribute is the SMIL Animation specification. In particular, see SMIL Animation: Specifying the animation target.
Value | |
---|---|
Default value | None |
Animatable | No |
feImage
For , href defines a URL referring to an image resource or to an element. If both, the xlink:href and the href attribute are specified, the latter overrides the former.
Value | |
---|---|
Default value | None |
Animatable | Yes |
image
Value | |
---|---|
Default value | None |
Animatable | Yes |
html, body, svg height: 100%; >
svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> image href="fxlogo.png" x="0" y="0" height="100" width="100" /> svg>
linearGradient
Value | |
---|---|
Default value | None |
Animatable | Yes |
mpath
Value | |
---|---|
Default value | None |
Animatable | No |
pattern
Value | |
---|---|
Default value | None |
Animatable | Yes |
radialGradient
Value | |
---|---|
Default value | None |
Animatable | Yes |
script
Value | |
---|---|
Default value | None |
Animatable | No |
textPath
Value | |
---|---|
Default value | None |
Animatable | Yes |
use
The element can reference an entire SVG document by specifying an href value without a fragment. Such references are taken to be referring to the root element of the referenced document.
Value | |
---|---|
Default value | None |
Animatable | Yes |
Specifications
Browser compatibility
BCD tables only load in the browser
See also
Found a content problem with this page?
This page was last modified on Jul 17, 2023 by MDN contributors.
Your blueprint for a better internet.
Html и svg ссылка
SVG элемент создаёт гиперссылку на другие веб-страницы, файлы, позиции в этом же документе, email-адреса или другие URL. Очень похож на элемент HTML .
@namespace svg url(http://www.w3.org/2000/svg); html,body,svg height:100% >
svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> a href="/docs/Web/SVG/Element/circle"> circle cx="50" cy="40" r="35"/> a> a href="/docs/Web/SVG/Element/text"> text x="50" y="90" text-anchor="middle"> <circle> text> a> svg>
/* Так как SVG не предоставляет визуальных стилей по умолчанию для ссылок, будет лучше задать самостоятельно */ @namespace svg url(http://www.w3.org/2000/svg); /* Необходимо выделить только SVG элементы , но не HTML. Смотрите предупреждение ниже */ svg|a:link, svg|a:visited cursor: pointer; > svg|a text, text svg|a fill: blue; /* Даже для текста SVG использует заливку */ text-decoration: underline; > svg|a:hover, svg|a:active outline: dotted 1px blue; >
Предупреждение: Поскольку этот элемент разделяет своё имя с элементом HTML , выбор a через CSS или querySelector может выбрать не тот тип элемента. Попробуйте правило @namespace , чтобы разделять их.
Атрибуты
Указывает браузеру выполнить загрузку по URL, вместо того, чтобы переходить по нему. Таким образом пользователю будет предложено сохранить файл локально. Тип: ;Значение по умолчанию: none;Анимируем: нет
URL или фрагмент URL для перехода. Тип: ; Значение по умолчанию: none; Анимируем: да
URL на человеческом языке или фрагмент URL для перехода. Тип: ; Значение по умолчанию: none; Анимируем: да
Разделённый пробелами список URL при переходе по которым браузер будет отправлять POST запросы с телом PING (в фоне). Обычно используется для трекинга. Тип: ; Значение по умолчанию: none; Анимируем: нет
Какой referrer отправить при получении URL. Тип: no-referrer | no-referrer-when-downgrade | same-origin | origin | strict-origin | origin-when-cross-origin | strict-origin-when-cross-origin | unsafe-url ; Значение по умолчанию: none; Анимируем: нет
Отношение между целевым объектом и объектом link. Тип: ; Значение по умолчанию: none; Анимируем: да
Где отобразить переход URL. Тип: _self | _parent | _top | _blank | ; Значение по умолчанию: _self ; Анимируем: да
MIME type для ссылки URL. Тип: ; Значение по умолчанию: none; Анимируем: да
URL или фрагмент URL, на который указывает гиперссылка. Может понадобиться для обратной совместимости со старыми браузерами. Тип: ; Значение по умолчанию: none; Анимируем: да
Глобальные атрибуты
aria-activedescendant , aria-atomic , aria-autocomplete , aria-busy , aria-checked , aria-colcount , aria-colindex , aria-colspan , aria-controls , aria-current , aria-describedby , aria-details , aria-disabled , aria-dropeffect , aria-errormessage , aria-expanded , aria-flowto , aria-grabbed , aria-haspopup , aria-hidden , aria-invalid , aria-keyshortcuts , aria-label , aria-labelledby , aria-level , aria-live , aria-modal , aria-multiline , aria-multiselectable , aria-orientation , aria-owns , aria-placeholder , aria-posinset , aria-pressed , aria-readonly , aria-relevant , aria-required , aria-roledescription , aria-rowcount , aria-rowindex , aria-rowspan , aria-selected , aria-setsize , aria-sort , aria-valuemax , aria-valuemin , aria-valuenow , aria-valuetext , role
Интерфейс DOM
Примечания к использованию
Спецификации
Совместимость с браузерами
BCD tables only load in the browser
Found a content problem with this page?
This page was last modified on 21 июн. 2023 г. by MDN contributors.
Your blueprint for a better internet.
MDN
Support
Our communities
Developers
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998– 2023 by individual mozilla.org contributors. Content available under a Creative Commons license.
Html и svg ссылка
Элемент SVG создает гиперссылку на другие веб-страницы, файлы, местоположения на той же странице, адреса электронной почты или любой другой URL-адрес. Он очень похож на HTML- элемент .
Example
svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> a href="/docs/Web/SVG/Element/circle"> circle cx="50" cy="40" r="35"/> a> a href="/docs/Web/SVG/Element/text"> text x="50" y="90" text-anchor="middle"> <circle> text> a> svg>
/ * Поскольку SVG не предоставляет визуальный стиль по умолчанию для ссылок, рекомендуется добавить некоторые * / @namespace svg url(http://www.w3.org/2000/svg); /* Необходимо выбрать только элементы SVG , а не элементы HTML. См. предупреждение ниже */ svg|a:link, svg|a:visited < cursor: pointer; > svg|a text, text svg|a < fill: blue; / * Даже для текста SVG использует заливку поверх цвета * / text-decoration: underline; > svg|a:hover, svg|a:active < outline: dotted 1px blue; >
Предупреждение: поскольку этот элемент имеет общее имя тега с элементом HTML , выбор a с помощью CSS или querySelector может применяться к неправильному типу элемента. Попробуйте в @namespace правило различать два.
Attributes
Указывает браузерам загружать URL-адрес вместо перехода к нему, поэтому пользователю будет предложено сохранить его как локальный файл. Тип значения : ; Значение по умолчанию : нет ; Анимируемый : нет
URL или URL фрагмента точки гиперссылок в. Тип значения : ; Значение по умолчанию : нет ; Анимируемый : да
Человеческий язык URL-адреса или фрагмента URL-адреса, на который указывает гиперссылка. Тип значения : ; Значение по умолчанию : нет ; Анимируемый : да
Список URL-адресов, разделенных пробелами, на которые при переходе по гиперссылке браузер отправляет POST — запросы с PING (в фоновом режиме). Обычно используется для отслеживания. Для более широко поддерживаемой функции, предназначенной для тех же вариантов использования, см. Navigator.sendBeacon() . Тип значения : ; Значение по умолчанию : нет ; Анимируемый : нет
Какой реферер отправлять при получении URL . Тип значения : no-referrer | no-referrer-when-downgrade | same-origin | origin | strict-origin | origin-when-cross-origin | strict-origin-when-cross-origin | unsafe-url ; Значение по умолчанию : нет ; Анимируемый : нет
Отношение целевого объекта к объекту ссылки. Тип значения : ; Значение по умолчанию : нет ; Анимируемый : да
Где отображать связанный URL . Тип значения : _self | _parent | _top | _blank | ; Значение по умолчанию : _self ; Анимируемый : да
Тип MIME для связанного URL. Тип значения : ; Значение по умолчанию : нет ; Анимируемый : да
URL-адрес или фрагмент URL-адреса, на который указывает гиперссылка. Может потребоваться для обратной совместимости со старыми браузерами. Тип значения : ; Значение по умолчанию : нет ; Анимируемый : да
Global attributes
aria-activedescendant , aria-atomic , aria-autocomplete , aria-busy , aria-checked , aria-colcount , aria-colindex , aria-colspan , aria-controls , aria-current , aria-describedby , aria-details , aria-disabled , aria-dropeffect , aria-errormessage , aria-expanded , aria-flowto , aria-grabbed , aria-haspopup , aria-hidden , aria-invalid , aria-keyshortcuts , aria-label , aria-labelledby , aria-level , aria-live , aria-modal , aria-multiline , aria-multiselectable , aria-orientation , aria-owns , aria-placeholder , aria-posinset , aria-pressed , aria-readonly , aria-relevant , aria-required , aria-roledescription , aria-rowcount , aria-rowindex , aria-rowspan , aria-selected , aria-setsize , aria-sort , aria-valuemax , aria-valuemin , aria-valuenow , aria-valuetext , role
Usage notes
Categories | Container element |
---|---|
Permitted content | Любое количество следующих элементов,в любом порядке: Animation elements Descriptive elements Shape elements Structural elements Gradient elements , , , , , , , , , , , , , , , , , |