Главная

HTML-тег <svg>

Характеристики

Атрибуты

Пример использования

<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
  <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
</svg>

Использование в JavaScript

// Получение SVG элемента
const svgElement = document.querySelector('svg');

// Добавление нового круга
const newCircle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
newCircle.setAttribute('cx', '50');
newCircle.setAttribute('cy', '50');
newCircle.setAttribute('r', '30');
newCircle.setAttribute('stroke', 'blue');
newCircle.setAttribute('stroke-width', '2');
newCircle.setAttribute('fill', 'red');
svgElement.appendChild(newCircle);

Рекомендации по обеспечению доступности (a11y)

Полезные ссылки