Related Articles

Related Articles

SVG height Attribute
  • Last Updated : 15 Oct, 2020

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 attribute
  • percentage: 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 height attribute for setting the height of rect using length value.



filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<body>
    <svg viewBox="0 0 3000 1000" 
        xmlns="http://www.w3.org/2000/svg">
          
        <rect y="150" x="150" 
            width="50" height="60" />
          
        <rect y="300" x="150" 
            width="50" height="60" />
    </svg>
</body>
  
</html>

chevron_right


Output:

Example 2: In this example we will use the height attribute for setting the height of rect using percentage value.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<body>
    <svg viewBox="0 0 3000 1000" 
        xmlns="http://www.w3.org/2000/svg">
          
        <rect y="150" x="75" 
            width="12%" height="10%" />
          
        <rect y="300" x="75" 
            width="12%" height="10%" />
    </svg>
</body>
  
</html>

chevron_right


Output

full-stack-img




My Personal Notes arrow_drop_up
Recommended Articles
Page :