Open In App

SVG y1 Attribute

Last Updated : 31 Mar, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

The y1 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:

y1 = "y1-coordinate"

Attribute Values:

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

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

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

html
<!DOCTYPE html>
<html>

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

</html>

Output:

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

html
<!DOCTYPE html>
<html>

<body>
    <svg viewBox="0 0 70 70" 
        xmlns="http://www.w3.org/2000/svg">

        <line x1="3%" x2="27%" y1="15%" 
            y2="15%" stroke="green" />
    </svg>
</body>

</html>

Output:


Next Article

Similar Reads