SVG Line

How to Draw an Line?

The <line> SVG element that draws lines with two connecting points.

In this example, we will draw a line from (0, 0) to (100, 100) by using <line> SVG element.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> svg line{ stroke:red; stroke-width:2; } </style> </head> <body> <svg height="150" width="150"> <line x1="0" y1="0" x2="100" y2="100" /> </svg> </body> </html>

Attributes Value

AttributeExplanation
x1Specifies the x-axis coordinate of the line starting point.
x2Specifies the x-axis coordinate of the line ending point.
y1Specifies the y-axis coordinate of the line starting point.
y2Specifies the y-axis coordinate of the line ending point.

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author