Various shapes can be drawn using HTML and CSS and so is the shape of a Half Moon, This shape can be drawn by manipulating a div element using some CSS Properties.
HTML Code: In this section we have a basic div tag.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Half Moon</title> </head> <body> <div></div> </body> </html> |
CSS Code: In this section we Draw the Half Moon by manipulating our div element, we will use the box-shadow and border-radius properties to draw the half-moon.
<style> *{ margin: 0; padding: 0; background-color: black; } /*Drawing the half moon by manipulating the div box*/ div{ position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); height: 100px; width: 100px; box-shadow: -15px 15px 0 5px white ; border-radius: 50%; } </style> |
Final Code: It is the combination of the above two code sections.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Half Moon</title> </head> <style> *{ margin: 0; padding: 0; background-color: black; } /*Drawing the half moon by manipulating the div box*/ div{ position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); height: 100px; width: 100px; box-shadow: -15px 15px 0 5px white ; border-radius: 50%; } </style> <body> <div></div> </body> </html> |
Output:
Recommended Posts:
- How to Draw a Semi-Circle using HTML and CSS ?
- How to draw with mouse in HTML 5 canvas ?
- HTML | Canvas Draw Bezier Curve
- How to set CSS style to half of a character ?
- p5.js | draw() Function
- How to Design Half-Page Carousel in Bootstrap ?
- How to Draw Graphics using Canvas in HTML5 ?
- How to draw Inscribed circle of a triangle using p5.js ?
- How to draw a circle with gradient border using CSS ?
- How to Draw a Curved Edge Hexagon using CSS ?
- How to Draw Smooth Curve Through Multiple Points using JavaScript ?
- Inline HTML Helper - HTML Helpers in ASP.NET MVC
- HTML | <html> xmlns Attribute
- HTML Course | Structure of an HTML Document
- HTML Course | Basics of HTML
- HTML | DOM HTML Object
- What is the difference between <html lang="en'> and <html lang="en-US'> ?
- HTML | <s> Tag
- HTML <ins> Tag
- HTML | <dd> Tag
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.


