How to Draw a Trapezium using HTML and CSS ?

A Trapezium is a Quadrilateral which has two parallel and two non-parallel sides. In this article we will create a Trapezium shape using simple HTML and CSS.

HTML Code: In this section, we will create a simple element using the HTML div tag.

HTML

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content=
    "width=device-width, initial-scale=1.0">
  <title>Trapezium</title>
</head>
  
<body>
  <div class="trapezium"></div>   
</body>
</html>

chevron_right


CSS Code: In this section, we will first design the div element using some basic CSS properties and then use the border-bottom, border-left and border-right properties to create the trapezium shape.

filter_none

edit
close

play_arrow

link
brightness_4
code

<style>
  * {
     margin: 0;
     padding: 0;
     background-color: white
  }
    
  /* creating the trapezium shape*/
  .trapezium {
     position: absolute;
     top: 50%;
     left: 50%;
     transform: translate(-50%, -50%);
     height: 0;
     width: 150px;
     border-bottom: 150px solid green;
     border-left: 100px solid transparent;
     border-right: 100px solid transparent;
  }
</style>

chevron_right


Final Code: It is the combination of the above two code sections.



HTML

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html lang="en">
  
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content=
    "width=device-width, initial-scale=1.0">
  <title>Trapezium</title>
  
  <style>
    * {
      margin: 0;
      padding: 0;
      background-color: white;
    }
  
    /* Creating the trapezium shape*/
    .trapezium {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      height: 0;
      width: 150px;
      border-bottom: 150px solid green;
      border-left: 100px solid transparent;
      border-right: 100px solid transparent;
    }
  </style>
</head>
  
<body>
  <div class="trapezium"></div>
</body>
  
</html>

chevron_right


Output:

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.