A
A
Artur Kudashev2019-07-28 15:07:31
css
Artur Kudashev, 2019-07-28 15:07:31

how to embed svg in html?

Hello, there is a mountain.svg file:

<svg width="24" height="14" viewBox="0 0 24 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9.83269 4.29038L8.55 4.90962L6.42692 3.40577L7.975 0.663462C8.46154 -0.221154 10.2308 -0.221154 10.7173 0.663462L13.1058 4.90962L10.4519 4.24615C10.2469 4.18561 10.027 4.20132 9.83269 4.29038ZM10.3192 6.01538L14.3 7.03269L18.1923 13.8885H0.5L5.49808 4.95385L7.93077 6.67885C8.1984 6.88249 8.55836 6.91678 8.85962 6.76731L10.3192 6.01538ZM19.7993 13.9327L14.8967 5.44116L15.7154 3.80385C16.1135 3.14038 17.4846 3.14038 17.8385 3.80385L23.5 13.9327H19.7993Z" fill="#5C2DAE"/>
</svg>

How to embed it in html file using svg tag?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Ankhena, 2019-07-28
@archi_kud

ctrl+c ctrl+v
https://jsfiddle.net/4ed5xjw7/

W
wisgest, 2019-07-29
@wisgest

<object id="svg1" type="image/svg+xml" data="mountain.svg"></object>

Can be changed via JS. If memory serves, the root element of the SVG can be reached with
document.getElementById("svg1").contentDocument.documentElement
.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question