Related Articles

Related Articles

SVG y2 Attribute
  • Last Updated : 15 Oct, 2020

The y2 attribute is used to specify the first y-coordinate for drawing an SVG element that requires more than one coordinate.

Elements that are using this attribute:

Syntax:

y2 = "y2-coordinate"

Attribute Values:

  • length: Length at which we want to set the y2-coordinate.
  • percentage: Percentage at which we want to set the y2-coordinate.

We will use the y2 attribute for setting the y2-coordinate.



Example 1: In this example we will use the length value.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<body>
    <svg viewBox="0 0 70 70" 
        xmlns="http://www.w3.org/2000/svg">
          
        <line x1="1" x2="9" y1="7" 
            y2="5" stroke="green" />
          
        <line x1="1" x2="9" y1="9" 
            y2="5" stroke="green" />
          
        <line x1="1" x2="9" y1="11" 
            y2="5" stroke="green" />
    </svg>
</body>
  
</html>

chevron_right


Output:

Example 2: In this example we will use the percentage value. 

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<body>
    <svg viewBox="0 0 70 70" 
        xmlns="http://www.w3.org/2000/svg">
          
        <line x1="4%" x2="36%" y1="7" 
            y2="5" stroke="green" />
          
        <line x1="4%" x2="36%" y1="9" 
            y2="5" stroke="green" />
          
        <line x1="4%" x2="36%" y1="11" 
            y2="5" stroke="green" />
    </svg>
</body>
  
</html>

chevron_right


Output:

full-stack-img




My Personal Notes arrow_drop_up
Recommended Articles
Page :