Line
The SVG line is one of the simplest in the library. It draws a straight line from
one point to another. The syntax is very straightforward and can be experimented with at: http://localhost:8080/chapter-2/line.html
, assuming the HTTP server is running:
<line x1="10" y1="10" x2="100" y2="100" stroke-width="1" stroke="red"/>
This will give you the following output:

A description of the element's attributes is as follows:
x1
andy1
: The starting x and y coordinatesx2
andy2
: The ending x and y coordinatesstroke
: This gives the line a red colorstroke-width
: This denotes the width of the line to be drawn in pixels
The line
tag also has the ability to change the style of the end of the line. For example, adding the following would change the image so it has round ends:
stroke-linecap: round;
As stated earlier, all SVG tags can also be styled with CSS elements. An alternative way of producing the same graphic would be to first create a CSS style, as shown in the following code:
line...