The Wayback Machine - https://web.archive.org/web/20241004003326/https://www.geeksforgeeks.org/svg-x1-attribute/
Open In App

SVG x1 Attribute

Last Updated : 31 Mar, 2022
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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:

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

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:



Previous Article
Next Article

Similar Reads

SVG <svg> Element
SVG stands for Scalable Vector Graphic. It can be used to make graphics and animations like in HTML canvas. SVG graphics are supported by the <svg> element in HTML. SVG graphics feature a container in which we can create a variety of shapes such as boxes, pathways, text, graphic images, and circles. Syntax: <svg width="x" height="y"> sh
2 min read
SVG from Attribute
The from attribute indicates the initial value of an attribute, it is used with to attribute. Syntax: from="number" Attribute Values: number: number at which we want to set from attributeWe will use the from attribute for setting the initial value. Example 1: C/C++ Code <!DOCTYPE html> <html> <body> <svg viewBox="0 0 1000
1 min read
SVG fill Attribute
The fill attribute can be used in two things. For shapes and text, it's a presentation attribute that defines the color used to paint the element. For animation it defines the final state of the animation. Syntax: fill= "colour" Attribute Values: paint: The color in which we want to paint the element. We will use the fill attribute for setting the
1 min read
SVG viewBox Attribute
The viewBox is an attribute of the SVG element in HTML. It is used to scale the SVG element that means we can set the coordinates as well as width and height. Syntax: viewBox = "min-x min-y width height" Attribute Values: min-x: It is used to set the horizontal axis. It is used to make the SVG move on a horizontal axis (i.e Left and Right).min-y: I
4 min read
SVG y Attribute
The y attribute defines the y-axis coordinate in the user coordinate system. Syntax: y = "y-coordinate" Attribute Values: length: length at which we want to set the x-axis. percentage: percentage at which we want to set the x-axis. We will use the y attribute for setting the y coordinate for the elements. Example 1: Group of rectangle elements with
1 min read
SVG x Attribute
The x attribute defines an x-axis coordinate in the user coordinate system. Syntax: x = "x-coordinate" Attribute Values: length: Length at which we want to set the x-axis.percentage: Percentage at which we want to set the x-axis.We will use the x attribute for setting x coordinate for the elements. Example 1: Rectangle element with the different x-
1 min read
SVG rx Attribute
The rx attribute defines a radius on the x-axis. Elements that are using this attribute: <ellipse> <rect> Syntax: rx = "x-radius" Attribute Values: length: Length at which we want to set the x-radius.percentage: Percentage at which we want to set the x-radius.We will use the rx attribute for setting the radius on the x-axis. Example 1:
1 min read
SVG opacity Attribute
The opacity attribute specifies the transparency of an object or of a group of objects. Syntax: opacity= "opacity" Attribute Values: decimal: The decimal at which we want to make our element opaque We will use the opacity attribute for setting the opacity of the element. Example 1: In this example we will use the opacity attribute for setting the o
1 min read
SVG stroke-width Attribute
The stroke-width attribute is an attribute defining the width of the stroke applied to the shape. Syntax: stroke-width="length" Attribute Values: length: Length at which we want to set the stroke-width attributepercentage: Percentage at which we want to set the stroke-width attribute We will use the stroke-width attribute for setting the width of t
1 min read
SVG stroke Attribute
The stroke attribute is an attribute defining the color used to paint the outline of the shape Syntax: stroke= "color" Attribute Values: paint: The color in which we want to paint the element. We will use the stroke attribute for setting the color of the element. Example 1: In this example, we will use the stroke attribute for setting the color of
1 min read
SVG height Attribute
The height attribute defines the vertical length of an element. Syntax: height= "height" Attribute Values: length: Length at which we want to set the height attributepercentage: Percentage at which we want to set the height attribute We will use the height attribute for setting the height of the element. Example 1: In this example, we will use the
1 min read
SVG ry Attribute
The ry attribute defines a radius on the y-axis. Elements that are using this attribute: <ellipse><rect> Syntax: ry = "y-radius" Attribute Values: length: Length at which we want to set the y-radius.percentage: Percentage at which we want to set the y-radius.We will use the ry attribute for setting the radius on the y-axis. Example 1:
1 min read
SVG y1 Attribute
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: <line><linearGradient> Syntax: y1 = "y1-coordinate" Attribute Values: length: :Length at which we want to set the y1-coordinate.percentage: Percentage at which we want to s
1 min read
SVG x2 Attribute
The x2 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: <line><linearGradient> Syntax: x2 = "x2-coordinate" Attribute Values: length: Length at which we want to set the x2-coordinate.percentage: Percentage at which we want to se
1 min read
SVG y2 Attribute
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: <line><linearGradient> Syntax: y2 = "y2-coordinate" Attribute Values: length: Length at which we want to set the y2-coordinate.percentage: Percentage at which we want to se
1 min read
SVG cy Attribute
The cy attribute defines the y-axis coordinate of a center point. Syntax: cyx="y-centre"Attribute Values: length: Length at which we want to set the cy-coordinate.percentage: Percentage at which we want to set the cy-coordinate.We will use the cy attribute for setting the cy-coordinate. Example 1: C/C++ Code <!DOCTYPE html> <html> <b
1 min read
SVG cx Attribute
The cx attribute define the x-axis coordinate of a center point. Syntax: cx="x-centre" Attribute Values: length: Length at which we want to set the cx-coordinate.percentage: Percentage at which we want to set the cx-coordinate. We will use the cx attribute for setting the cx-coordinate. Example 1: <!DOCTYPE html> <html> <body>
1 min read
SVG stroke-dasharray Attribute
The stroke-dasharray attribute is a presentation attribute defining the pattern of dashes used to paint the outline of the shape. Syntax: stroke-dasharray="number pattern" Attribute Values: dasharray: The pattern stroke that will have. We will use the stoke-dasharray attribute for setting the pattern of the stroke. Example 1: In this example we wil
1 min read
SVG fr Attribute
The fr attribute defines the radius of the focal point for the linear gradient. Syntax: fr="radius" Attribute Values: length: Length at which we want to set the radius.percentage: Percentage at which we want to set the radius.We will use the fr attribute for setting the radius of the element. Example 1: C/C++ Code <!DOCTYPE html> <html>
1 min read
SVG stroke-opacity Attribute
The stroke-opacity attribute specifies the transparency of an object or of a group of objects. Syntax: stroke-opacity= "opacity" Attribute Values: decimal: decimal value ranging from 0-1percentage: percentage at which we want to set the opacity of the element We will use the stoke-opacity attribute for setting the opacity of the element. Example 1:
1 min read
SVG stroke-linecap Attribute
The stroke-linecap attribute defines the shape of the stroke that is to be used at the end of the open subpath. This is the presentation attribute. Syntax: stroke-linecap="shapes" Attribute Values: butt: This attribute value indicates that the stroke does not extend beyond its two endpoints. round: This attribute value indicates that the stroke wil
1 min read
SVG font-size Attribute
The font-size attribute refers to the size of the font from baseline when multiple lines of text are set solid in a multiline layout environment. Syntax: font-size="size" Attribute Values: length: Length at which we want to set the size.percentage: Percentage at which we want to set the size. We will use the font size attribute for setting the size
1 min read
SVG flood-color Attribute
The flood-color attribute indicates what color is used to flood the current filter primitive subregion. Syntax: flood-color="color" Attribute Values: color: The color that we want to flood. We will use the flood-color attribute for setting the flood color. Example 1: <!DOCTYPE html> <html> <body> <svg viewBox="0 0 4000 200
1 min read
SVG fill-opacity Attribute
The fill-opacity attribute is a presentation attribute defining the opacity of the paint applied to a shape. Syntax: fill-opacity="colour" Attribute Values: decimal: Decimal value at which we want to make our element opaque.percentage: Percentage at which we want to set the fill-opacity attribute. We will use the fill-opacity attribute for setting
1 min read
SVG flood-opacity Attribute
The flood-opacity attribute indicates the opacity value to use across the current filter primitive subregion. Syntax: flood-opacity="flood" Attribute Values: flood: A number or percentage indicating the opacity value to use across the current filter primitive subregion We will use the fill-opacity attribute for setting the opacity of fill-color. Ex
1 min read
SVG font-style Attribute
The font-style attribute is used to specify whether the text is to be rendered using a normal, italic, or oblique face style. Syntax: font-style="style" Attribute Values: The attribute can have the following values: normal: This specifies that the text should be displayed in the normal form.italic: This specifies that the text should be displayed i
1 min read
SVG filter Attribute
The filter attribute is used to specify the filter effects that are defined by the <filter> element which are to be applied to its elements. Syntax: filter="value" Attribute values: value: The filter values to be applied to the element We will use the filter attribute for setting the filter of the elements. Example 1: C/C++ Code <!DOCTYPE
1 min read
SVG r Attribute
The r attribute defines the radius of the circle. Syntax: r="radius" Attribute Values: length: length at which we want to set the radius.percentage: percentage at which we want to set the radius.We will use the r attribute for setting the radius of the circle Example1: C/C++ Code <!DOCTYPE html> <html> <body> <svg viewBox=
1 min read
SVG tabindex Attribute
The tabindex attribute allows one to control whether an element is focusable or not. It also defines the relative order in which the elements are focused. All SVG elements can be used with this attribute. Syntax: tabindex="integer" Attribute Values: integer: It is an integer that determines the relative order of the focus navigation. The below exam
1 min read
SVG by Attribute
The by attribute specifies a relative offset value for an attribute that will be modified during an animation. Syntax: by="numbers" Attribute Values: integers: Integer at which we want to set the by attribute. We will use the by attribute for adjusting the size of the shape. Example 1: C/C++ Code <!DOCTYPE html> <html> <body> <
1 min read