Search code examples
htmlcsscss-shapes

how to make an oval in css?


I want to make an oval like:

enter image description here

But when i used this code:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html"; charset="utf-8" />
        <title>Oval</title>
        <style type="text/css">
            .oval {
                width: 160px;
                height: 80px;
                background: #a84909;
                border-radius: 40px;
            }
        </style>
    </head>
    <body>
        <div class="oval"></div>
    </body>
</html>

It gives me this:

enter image description here

To make a circle it works, but an oval not.


Solution

  • All you have to do is to change border-radius: 40px to border-radius: 50%.

    .oval {
      width: 160px;
      height: 80px;
      background: #a84909;
      border-radius: 50%;
    }
    <div class="oval"></div>