
- SVG Tutorial
- SVG - Home
- SVG - Overview
- SVG - Shapes
- SVG - Text
- SVG - Stroke
- SVG - Filters
- SVG - Patterns
- SVG - Gradients
- SVG - Interactivity
- SVG - Linking
- SVG Demo
- SVG - Loaders
- SVG - Dialog
- SVG - Icons
- SVG - Clock
- SVG - Drag
- SVG - Key point
- SVG - Maps
- SVG - amChart
- SVG - Graph
- SVG - Flat Surface Shade
- SVG - Image Filter
- SVG - Text Effects
- SVG - Text With CSS Effects
- SVG - Arrow Effects
- SVG - Brand Effects
- SVG - Gooey Effects
- SVG - Gradients Effects
- SVG - Playful Effects
- SVG - Scroll Effects
- SVG - Side Show Effects
- SVG - Tab Effects
- SVG - Raphael.js Effects
- SVG - Velocity.js Effects
- SVG - Walkway.js Effects
- SVG - zPath.js Effects
- SVG - Vague.js Effects
- SVG - Transformation Effects
- SVG - Full Screen Overlay Effects
- SVG - Lazylinepainter.js Effects
- SVG - Demo Game
- SVG - Real Time SVG AD
- SVG Useful Resources
- SVG - Questions and Answers
- SVG - Quick Guide
- SVG - Useful Resources
- SVG - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
SVG - Line
<line> element is used to draw line with a start point and end point.
Declaration
Following is the syntax declaration of <line> element. We've shown main attributes only.
<line x1="x-axis co-ordinate" y1="y-axis co-ordinate" x2="x-axis co-ordinate" y2="y-axis co-ordinate" > </line>
Attributes
Sr.No. | Name&Description |
---|---|
1 | x1 − x-axis co-ordinate of the start point. Default is 0. |
2 | y1 − y-axis co-ordinate of the start point. Default is 0. |
3 | x2 − x-axis co-ordinate of the end point. Default is 0. |
4 | y2 − y-axis co-ordinate of the end point. Default is 0. |
Example
testSVG.htm<html> <title>SVG Line</title> <body> <h1>Sample SVG Line Image</h1> <svg width="800" height="800"> <g> <text x="0" y="15" fill="black" >Line #1: Without opacity.</text> <line x1="20" y1="20" x2="150" y2="150" stroke="black" stroke-width="3" fill="rgb(121,0,121)"></line> </g> </svg> </body> </html>
Output
Open textSVG.htm in Chrome web browser. You can use Chrome/Firefox/Opera to view SVG image directly without any plugin. Internet Explorer 9 and higher also supports SVG image rendering.
Line with opacity
<html> <title>SVG Line</title> <body> <h1>Sam>le SVG Line Image</h1> <svg width="800" height="800"> <g> <text x="0" y="15" fill="black" >Line #2: With opacity </text> <line x1="20" y1="20" x2="150" y2="150" style="fill:rgb(121,0,121);stroke-width:3; stroke:rgb(0,0,0);stroke-opacity:0.5;opacity:0.5"></line> </g> </svg> </body> </html>
Output
Open textSVG.htm in Chrome web browser. You can use Chrome/Firefox/Opera to view SVG image directly without any plugin. Internet Explorer 9 and higher also supports SVG image rendering.
svg_shapes.htm
Advertisements