Skip to content
Related Articles

Related Articles

Improve Article

SVG stroke Attribute

  • Last Updated : 15 Oct, 2020
Geek Week

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 circle element.






<!DOCTYPE html>
<html>
  
<body>
    <svg viewBox="0 0 200 100" 
        xmlns="http://www.w3.org/2000/svg">
          
        <circle cx="10" cy="10" r="5" 
            fill="none" stroke="green" />
          
        <circle cx="23" cy="23" r="9" 
            fill="none" stroke="green" />
    </svg>
</body>
  
</html>

Output:

Example 2: In this example, we will use the stroke attribute for setting the color of rect element.




<!DOCTYPE html>
<html>
  
<body>
    <svg viewBox="0 0 200 100" 
        xmlns="http://www.w3.org/2000/svg">
          
        <rect x="10" y="10" height="11" 
            width="11" fill="none" stroke="green" />
          
        <rect x="23" y="23" height="22" 
            width="22" fill="none" stroke="green" />
    </svg>
</body>
  
</html>

Output:

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :