{"id":9307,"date":"2022-10-06T04:43:15","date_gmt":"2022-10-06T04:43:15","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=9307"},"modified":"2022-10-06T04:43:15","modified_gmt":"2022-10-06T04:43:15","slug":"svg-text","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/10\/06\/svg-text\/","title":{"rendered":"SVG Text"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"description-of-the-lt-text-gt-element-1\">Description of the &lt;text&gt; element<\/h2>\n\n\n\n<p>The SVG &lt;text&gt; element specifies a graphics element consisting of a text. It is possible to apply a pattern, clipping path, mask, gradient, or filter to &lt;text&gt;, like other SVG graphics elements. The text not included within a &lt;text&gt; element will not be rendered. Whereas the text included within a &lt;text&gt; element can be rendered auto-wrapped, pre-formatted, or on a path.<\/p>\n\n\n\n<p>SVG text supports such typographic features as text decorations, choice of typeface, and use of discretionary, stylistic, or historical ligatures.<\/p>\n\n\n\n<p>SVG also supports international text processing needs:<\/p>\n\n\n\n<ul><li>left-to-right or bidirectional text,<\/li><li>the vertical and horizontal orientation of text,<\/li><li>complex text layout,<\/li><li>glyph alignment to different baselines.<\/li><\/ul>\n\n\n\n<p>It is possible to have multi-language SVG content by substituting various text strings based on the preferred language of the user.<\/p>\n\n\n\n<p>To style text, you can use text-specific CSS properties such as\u00a0font-family,\u00a0font-size,\u00a0kerning,\u00a0letter-spacing,\u00a0word-spacing,\u00a0text-decoration,\u00a0stroke,\u00a0stroke-width, and\u00a0fill.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-svg-lt-text-gt-element-3\">Example of the SVG &lt;text&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;svg width=\"250\" height=\"60\" &gt;\n      &lt;text x=\"20\" y=\"25\" fill=\"purple\"&gt;This is a SVG text example.&lt;\/text&gt;\n      Sorry, your browser doesn't support inline SVG.\n    &lt;\/svg&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-svg-lt-text-gt-element-with-the-span-class-attribute-rotate-span-attribute-5\">Example of the SVG &lt;text&gt; element with the&nbsp;rotate&nbsp;attribute:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;svg width=\"250\" height=\"150\" style=\"border:1px solid red\"&gt;\n      &lt;text x=\"20\" y=\"25\" fill=\"purple\" transform=\"rotate(40 30,60)\"&gt;This is a SVG text example.&lt;\/text&gt;\n      Sorry, your browser doesn't support inline SVG.\n    &lt;\/svg&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p>In the following example, the &lt;text&gt; element is used with the &lt;tspan&gt; element, which can contain different formatting and position.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-svg-lt-text-gt-element-used-with-the-lt-tspan-gt-element-8\">Example of the SVG &lt;text&gt; element used with the &lt;tspan&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;svg width=\"450\" height=\"150\" style=\"border:1px solid #cccccc\"&gt;\n      &lt;text x=\"20\" y=\"20\" style=\"fill:green\"&gt;\n        Example of the SVG \"text\" element used with the \"tspan\" element\n        &lt;tspan x=\"25\" y=\"65\"&gt;This is a SVG text.&lt;\/tspan&gt;\n        &lt;tspan x=\"35\" y=\"90\"&gt;This is a SVG text.&lt;\/tspan&gt;\n        &lt;tspan x=\"45\" y=\"115\"&gt;This is a SVG text.&lt;\/tspan&gt;\n      &lt;\/text&gt;\n      Sorry, your browser doesn't support inline SVG.\n    &lt;\/svg&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-svg-lt-text-gt-element-used-with-the-lt-a-gt-element-10\">Example of the SVG &lt;text&gt; element used with the &lt;a&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;svg  width=\"250\" height=\"60\" xmlns:xlink=\"http:\/\/www.w3.org\/1999\/xlink\" style=\"border:1px solid #cccccc\"&gt;\n      &lt;a xlink:href=\"https:\/\/www.w3docs.com\/learn-html\/svg-intro.html\" target=\"_blank\"&gt;\n        &lt;text x=\"20\" y=\"40\" fill=\"blue\" font-size=\"2em\"&gt;SVG Intro&lt;\/text&gt;\n      &lt;\/a&gt;\n      Sorry, your browser doesn't support inline SVG.\n    &lt;\/svg&gt;\n  &lt;\/body&gt;\n  &lt;\/html<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"attributes-12\">Attributes<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Attribute<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>x<\/td><td>Specifies the starting x coordinate of the text baseline.<\/td><\/tr><tr><td>y<\/td><td>Specifies the starting y coordinate of the text baseline.<\/td><\/tr><tr><td>dx<\/td><td>Specifies a text position\u2019s horizontal shift from a previous text position.<\/td><\/tr><tr><td>dy<\/td><td>Specifies a text position\u2019s vertical shift from a previous text position.<\/td><\/tr><tr><td>rotate<\/td><td>Specifies the rotation of orientation for each individual glyph.<\/td><\/tr><tr><td>lenghtAdjust<\/td><td>Specifies how the text is compressed or stretched for fitting the width defined by the textLenght attribute.<\/td><\/tr><tr><td>textLenght<\/td><td>Specifies the width that the text must fit.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>The SVG &lt;text> element also supports the\u00a0Global Attributes\u00a0and\u00a0Event Attributes.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description of the &lt;text&gt; element The SVG &lt;text&gt; element specifies a graphics element consisting of a text. It is possible to apply a pattern, clipping path, mask, gradient, or filter to &lt;text&gt;, like other SVG graphics elements. The text not included within a &lt;text&gt; element will not be rendered. Whereas the text included within a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[574],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/9307"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=9307"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/9307\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=9307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=9307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=9307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}