본문 바로가기
HTML5/SVG

SVG Text

by Jundol 2015. 6. 8.

* 본 글은 W3SCHOOL.COM 의 SVG 편을 해석 공부한 포스팅입니다.

* 필자의 기준이 절대적인 진리는 아닙니다.

SVG Text - <text>

<text> 태그는 text를 정의할때 사용한다.


예제 1

text를 쓴다:

I love SVG! Sorry, your browser does not support inline SVG.

SVG 코드

<svg height="30" width="200">
  <text x="0" y="15" fill="red">I love SVG!</text>
</svg>


예제 2

텍스트 회전

I love SVG Sorry, your browser does not support inline SVG.

SVG 코드

<svg height="60" width="200">
  <text x="0" y="15" fill="red" transform="rotate(30 20,40)">I love SVG</text>
</svg>


예제 3

텍스트 태그는 <tspan>태그를 이용하여 각각의 text들을 정렬 할 수 있다. 각각의 <tspan>태그들은 다른 포맷과 위치를 가지고 있다.

Several lines: First line. Second line. Sorry, your browser does not support inline SVG.

SVG 코드

<svg height="90" width="200">
  <text x="10" y="20" style="fill:red;">Several lines:
    <tspan x="10" y="45">First line.</tspan>
    <tspan x="10" y="70">Second line.</tspan>
  </text>
</svg>


예제 4

텍스트에 하이퍼링크 걸기 <a>태그와 결합

I love SVG! Sorry, your browser does not support inline SVG.

SVG 코드

<svg height="30" width="200" xmlns:xlink="http://www.w3.org/1999/xlink">
  <a xlink:href="http://www.w3schools.com/svg/" target="_blank">
    <text x="0" y="15" fill="red">I love SVG!</text>
  </a>
</svg>


출처 W3School.com - SVG - Text

http://www.w3schools.com/svg/svg_text.asp

'HTML5 > SVG' 카테고리의 다른 글

SVG Filters  (0) 2015.06.09
SVG Stroking  (0) 2015.06.08
SVG Path  (0) 2015.06.08
SVG Polyline  (0) 2015.06.08
SVG Polygon  (0) 2015.06.08

댓글