Open In App

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:

We will use the stoke-linecap attribute for defining the shape of the stroke.



Example 1:




<!DOCTYPE html> 
<html
  
<body
    <svg viewBox="0 0 35 30" 
         xmlns="http://www.w3.org/2000/svg">
  
        <line x1="1" y1="1" x2="5" y2="1" stroke="black"
        stroke-linecap="butt" />
  
    </svg>
</body
  
</html>

Output:

Example 2:




<!DOCTYPE html> 
<html
  
<body
    <svg viewBox="0 0 35 30" 
         xmlns="http://www.w3.org/2000/svg">
  
        <line x1="1" y1="3" x2="5" y2="3" stroke="black"
        stroke-linecap="round" />
  
    </svg>
</body
  
</html>

Output:

Example 3:




<!DOCTYPE html> 
<html
  
<body
    <svg viewBox="0 0 35 30" 
         xmlns="http://www.w3.org/2000/svg">
  
        <line x1="1" y1="5" x2="5" y2="5" stroke="black"
        stroke-linecap="square" />
  
    </svg>
</body
  
</html>

output:


Article Tags :