1# Text Drawing 2 3 4The **<svg>** component can also be used to draw text. 5 6 7## Text 8 9> **NOTE** 10> - The text content must be written in the **<text>** area. The **<tspan>** child element label can be nested. 11> 12> - **<text>** can be nested only by the parent element label **svg**. 13> 14> - Only the default font **sans-serif** is supported. 15 16Set the following attributes to define text styles: **x** (X coordinate), **y** (Y coordinate), **dx** (x-axis offset of the text), **dy** (y-axis offset of the text), **fill** (font fill color), **stroke** (text border color), and **stroke-width** (text border width). 17 18 19```html 20<!-- xxx.hml --> 21<div class="container"> 22 <svg> 23 <text x="200" y="300" font-size="80px" fill="blue" >Hello World</text> <text x="200" y="300" dx="20" dy="80" font-size="80px" fill="blue" fill-opacity="0.5" stroke="red" stroke-width="2">Hello World</text> 24 <text x="20" y="550" fill="#D2691E"> 25 <tspan dx="40" fill="red" font-size="80" fill-opacity="0.4">Hello World </tspan> 26 </text> 27 </svg> 28</div> 29``` 30 31![en-us_image_0000001275803145](figures/en-us_image_0000001275803145.png) 32 33 34## Drawing Text Along the Path 35 36Set **textpath** to draw text along the path. 37 38 39```html 40<!-- xxx.hml --> 41<div class="container"> 42 <svg fill="#00FF00" x="100" y="400"> 43 <path d="M40,360 Q360,360 360,180 Q360,20 200,20 Q40,40 40,160 Q40,280 180,180 Q180,180 200,100" stroke="red" fill="none"></path> 44 <text> 45 <textpath fill="blue" startOffset="20%" path="M40,360 Q360,360 360,180 Q360,20 200,20 Q40,40 40,160 Q40,280 180,180 Q180,180 200,100" font-size="30px"> 46 This is textpath test. 47 </textpath> 48 </text> 49 </svg> 50</div> 51``` 52 53![en-us_image_0000001231843084](figures/en-us_image_0000001231843084.png) 54