Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

SVG Line

SVG Line

In SVG, the The element is used to draw a straight line; it is one of the commonly used basic shapes in SVG.

Use The element can create a straight line between two points, and you can control the line's position, length, and style by setting attributes.

Basic Syntax



  y1="y1-coordinate"     

  x2="x2-coordinate"     

  y2="y2-coordinate"     

  stroke="stroke-color"  

  stroke-width="width"   

/>

Attribute analysis:

The following code draws a line with a black stroke and a width of 2 pixels, starting at (50, 50) and ending at (150, 150).



  



Example

Below is the SVG code:

Example

 

  style="stroke:rgb(255,0,0);stroke-width:2"/>

Try it »

Click to view:View SVG File.