Skip to content
Related Articles

Related Articles

How to Draw a Trapezium using HTML and CSS ?
  • Last Updated : 13 Aug, 2020

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




<!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>

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.




<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>

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

HTML




<!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>

Output:




My Personal Notes arrow_drop_up
Recommended Articles
Page :