{"id":24403,"date":"2022-12-02T18:38:43","date_gmt":"2022-12-02T13:08:43","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-rendering-svg-into-html-element\/"},"modified":"2022-12-02T18:38:43","modified_gmt":"2022-12-02T13:08:43","slug":"solved-rendering-svg-into-html-element","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-rendering-svg-into-html-element\/","title":{"rendered":"[Solved] Rendering SVG into HTML element"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-40659717\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"40659717\" data-parentid=\"40659573\" data-score=\"1\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>Create a div in your html, set an id for it, get the element created by ID, append the child content into the new div.<\/p>\n<pre><code>var chatInProgressText = \"&lt;svg id='Layer_4' data-name=\"Layer 4\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox='0 0 30 30'&gt;\\n    &lt;defs&gt;&lt;style&gt;.cls-1{fill:#474747;}.cls-2{fill:#fff;}&lt;\/style&gt;&lt;\/defs&gt;\\n    &lt;title&gt;chat-live-icon&lt;\/title&gt;\\n    &lt;path class=\"cls-1\" d='M15.08,0C6.76,0,0,5.17,0,11.51,0,17.14,5.42,22,12.65,22.88L11.77,27a1.16,1.16,0,0,0,.43,1,1.14,1.14,0,0,0,.71.24,1.3,1.3,0,0,0,.35,0l.1,0c1.86-.76,4.91-4.15,6.2-5.65,6.35-1.5,10.6-5.91,10.6-11C30.15,5.17,23.39,0,15.08,0Z'\/&gt;&lt;path class=\"cls-2\" d='M19.08,20.85a1.44,1.44,0,0,0-.78.47,37.25,37.25,0,0,1-4.53,4.56L14.4,23a1.48,1.48,0,0,0-.24-1.18,1.5,1.5,0,0,0-1.05-.61c-6.48-.71-11.37-4.87-11.37-9.68,0-5.4,6-9.79,13.35-9.79s13.35,4.39,13.35,9.79C28.43,15.81,24.67,19.56,19.08,20.85Z'\/&gt;&lt;circle class=\"cls-1\" cx='8.14' cy='11.79' r=\"2\"\/&gt;&lt;circle class=\"cls-1\" cx='15.14' cy='11.79' r=\"2\"\/&gt;&lt;circle class=\"cls-1\" cx='22.14' cy='11.79' r=\"2\"\/&gt;\\n&lt;\/svg&gt;\";\nvar d1 = document.getElementById('svg');\nd1.insertAdjacentHTML('beforeend', chatInProgressText);\n<\/code><\/pre>\n<p><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/jsfiddle.net\/s6un2fpc\/1\/\">https:\/\/jsfiddle.net\/s6un2fpc\/1\/<\/a><\/p>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">1<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved Rendering SVG into HTML element <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] Create a div in your html, set an id for it, get the element created by ID, append the child content into the new div. var chatInProgressText = &#8220;&lt;svg id=&#8217;Layer_4&#8242; data-name=&#8221;Layer 4&#8243; xmlns=&#8221;http:\/\/www.w3.org\/2000\/svg&#8221; viewBox=&#8217;0 0 30 30&#8242;&gt;\\n &lt;defs&gt;&lt;style&gt;.cls-1{fill:#474747;}.cls-2{fill:#fff;}&lt;\/style&gt;&lt;\/defs&gt;\\n &lt;title&gt;chat-live-icon&lt;\/title&gt;\\n &lt;path class=&#8221;cls-1&#8243; d=&#8217;M15.08,0C6.76,0,0,5.17,0,11.51,0,17.14,5.42,22,12.65,22.88L11.77,27a1.16,1.16,0,0,0,.43,1,1.14,1.14,0,0,0,.71.24,1.3,1.3,0,0,0,.35,0l.1,0c1.86-.76,4.91-4.15,6.2-5.65,6.35-1.5,10.6-5.91,10.6-11C30.15,5.17,23.39,0,15.08,0Z&#8217;\/&gt;&lt;path class=&#8221;cls-2&#8243; d=&#8217;M19.08,20.85a1.44,1.44,0,0,0-.78.47,37.25,37.25,0,0,1-4.53,4.56L14.4,23a1.48,1.48,0,0,0-.24-1.18,1.5,1.5,0,0,0-1.05-.61c-6.48-.71-11.37-4.87-11.37-9.68,0-5.4,6-9.79,13.35-9.79s13.35,4.39,13.35,9.79C28.43,15.81,24.67,19.56,19.08,20.85Z&#8217;\/&gt;&lt;circle class=&#8221;cls-1&#8243; cx=&#8217;8.14&#8242; cy=&#8217;11.79&#8242; r=&#8221;2&#8243;\/&gt;&lt;circle class=&#8221;cls-1&#8243; cx=&#8217;15.14&#8242; cy=&#8217;11.79&#8242; r=&#8221;2&#8243;\/&gt;&lt;circle class=&#8221;cls-1&#8243; cx=&#8217;22.14&#8242; &#8230; <a title=\"[Solved] Rendering SVG into HTML element\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-rendering-svg-into-html-element\/\" aria-label=\"More on [Solved] Rendering SVG into HTML element\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[346,333,1729],"class_list":["post-24403","post","type-post","status-publish","format-standard","hentry","category-solved","tag-html","tag-javascript","tag-svg"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>[Solved] Rendering SVG into HTML element - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-rendering-svg-into-html-element\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] Rendering SVG into HTML element - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] Create a div in your html, set an id for it, get the element created by ID, append the child content into the new div. var chatInProgressText = &quot;&lt;svg id=&#039;Layer_4&#039; data-name=&quot;Layer 4&quot; xmlns=&quot;http:\/\/www.w3.org\/2000\/svg&quot; viewBox=&#039;0 0 30 30&#039;&gt;n &lt;defs&gt;&lt;style&gt;.cls-1{fill:#474747;}.cls-2{fill:#fff;}&lt;\/style&gt;&lt;\/defs&gt;n &lt;title&gt;chat-live-icon&lt;\/title&gt;n &lt;path class=&quot;cls-1&quot; d=&#039;M15.08,0C6.76,0,0,5.17,0,11.51,0,17.14,5.42,22,12.65,22.88L11.77,27a1.16,1.16,0,0,0,.43,1,1.14,1.14,0,0,0,.71.24,1.3,1.3,0,0,0,.35,0l.1,0c1.86-.76,4.91-4.15,6.2-5.65,6.35-1.5,10.6-5.91,10.6-11C30.15,5.17,23.39,0,15.08,0Z&#039;\/&gt;&lt;path class=&quot;cls-2&quot; d=&#039;M19.08,20.85a1.44,1.44,0,0,0-.78.47,37.25,37.25,0,0,1-4.53,4.56L14.4,23a1.48,1.48,0,0,0-.24-1.18,1.5,1.5,0,0,0-1.05-.61c-6.48-.71-11.37-4.87-11.37-9.68,0-5.4,6-9.79,13.35-9.79s13.35,4.39,13.35,9.79C28.43,15.81,24.67,19.56,19.08,20.85Z&#039;\/&gt;&lt;circle class=&quot;cls-1&quot; cx=&#039;8.14&#039; cy=&#039;11.79&#039; r=&quot;2&quot;\/&gt;&lt;circle class=&quot;cls-1&quot; cx=&#039;15.14&#039; cy=&#039;11.79&#039; r=&quot;2&quot;\/&gt;&lt;circle class=&quot;cls-1&quot; cx=&#039;22.14&#039; ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-rendering-svg-into-html-element\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-02T13:08:43+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-rendering-svg-into-html-element\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-rendering-svg-into-html-element\\\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#\\\/schema\\\/person\\\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] Rendering SVG into HTML element\",\"datePublished\":\"2022-12-02T13:08:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-rendering-svg-into-html-element\\\/\"},\"wordCount\":45,\"publisher\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#organization\"},\"keywords\":[\"html\",\"javascript\",\"svg\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-rendering-svg-into-html-element\\\/\",\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-rendering-svg-into-html-element\\\/\",\"name\":\"[Solved] Rendering SVG into HTML element - JassWeb\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#website\"},\"datePublished\":\"2022-12-02T13:08:43+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-rendering-svg-into-html-element\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-rendering-svg-into-html-element\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-rendering-svg-into-html-element\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] Rendering SVG into HTML element\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#website\",\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/jassweb.com\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/jass-website-logo-1.png\",\"contentUrl\":\"https:\\\/\\\/jassweb.com\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#\\\/schema\\\/person\\\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/wp-content\\\/litespeed\\\/avatar\\\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777613206\",\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/wp-content\\\/litespeed\\\/avatar\\\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777613206\",\"contentUrl\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/wp-content\\\/litespeed\\\/avatar\\\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777613206\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\\\/\\\/jassweb.com\"],\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/author\\\/jaspritsinghghumangmail-com\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] Rendering SVG into HTML element - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-rendering-svg-into-html-element\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] Rendering SVG into HTML element - JassWeb","og_description":"[ad_1] Create a div in your html, set an id for it, get the element created by ID, append the child content into the new div. var chatInProgressText = \"&lt;svg id='Layer_4' data-name=\"Layer 4\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox='0 0 30 30'&gt;n &lt;defs&gt;&lt;style&gt;.cls-1{fill:#474747;}.cls-2{fill:#fff;}&lt;\/style&gt;&lt;\/defs&gt;n &lt;title&gt;chat-live-icon&lt;\/title&gt;n &lt;path class=\"cls-1\" d='M15.08,0C6.76,0,0,5.17,0,11.51,0,17.14,5.42,22,12.65,22.88L11.77,27a1.16,1.16,0,0,0,.43,1,1.14,1.14,0,0,0,.71.24,1.3,1.3,0,0,0,.35,0l.1,0c1.86-.76,4.91-4.15,6.2-5.65,6.35-1.5,10.6-5.91,10.6-11C30.15,5.17,23.39,0,15.08,0Z'\/&gt;&lt;path class=\"cls-2\" d='M19.08,20.85a1.44,1.44,0,0,0-.78.47,37.25,37.25,0,0,1-4.53,4.56L14.4,23a1.48,1.48,0,0,0-.24-1.18,1.5,1.5,0,0,0-1.05-.61c-6.48-.71-11.37-4.87-11.37-9.68,0-5.4,6-9.79,13.35-9.79s13.35,4.39,13.35,9.79C28.43,15.81,24.67,19.56,19.08,20.85Z'\/&gt;&lt;circle class=\"cls-1\" cx='8.14' cy='11.79' r=\"2\"\/&gt;&lt;circle class=\"cls-1\" cx='15.14' cy='11.79' r=\"2\"\/&gt;&lt;circle class=\"cls-1\" cx='22.14' ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-rendering-svg-into-html-element\/","og_site_name":"JassWeb","article_published_time":"2022-12-02T13:08:43+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-rendering-svg-into-html-element\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-rendering-svg-into-html-element\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] Rendering SVG into HTML element","datePublished":"2022-12-02T13:08:43+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-rendering-svg-into-html-element\/"},"wordCount":45,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["html","javascript","svg"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-rendering-svg-into-html-element\/","url":"https:\/\/jassweb.com\/solved\/solved-rendering-svg-into-html-element\/","name":"[Solved] Rendering SVG into HTML element - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-12-02T13:08:43+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-rendering-svg-into-html-element\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-rendering-svg-into-html-element\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-rendering-svg-into-html-element\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] Rendering SVG into HTML element"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777613206","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777613206","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777613206","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/24403","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=24403"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/24403\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=24403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=24403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=24403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}