Open In App

SVG x1 Attribute

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

Elements that are using this attribute:



Syntax:

x1 = "x1-coordinate"

Attribute Values:



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

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




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

Output:

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




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

Output:


Article Tags :