how to make an oval in css?

rachid picture rachid · Nov 16, 2014 · Viewed 45k times · Source

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.

Answer

Ali Aboussebaba picture Ali Aboussebaba · Nov 16, 2014

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>