{"id":485,"date":"2022-02-16T11:38:24","date_gmt":"2022-02-16T11:38:24","guid":{"rendered":"http:\/\/frontendguruji.com\/?p=485"},"modified":"2022-02-16T11:51:05","modified_gmt":"2022-02-16T11:51:05","slug":"how-to-create-shapes-in-css-heart-triangle-star","status":"publish","type":"post","link":"https:\/\/frontendguruji.com\/blog\/how-to-create-shapes-in-css-heart-triangle-star\/","title":{"rendered":"How to Create Shapes in CSS [&#x1f497; &#x1f53a; &#x2b50;]"},"content":{"rendered":"\n<p>Hello Friends &#x1f64f;,&nbsp;I think CSS is the most underrated language. I see developers trying to do crazy stuff using JavaScript or jQuery to achieve something that can be done in CSS with some tricks.<\/p>\n\n\n\n<p>In this<strong> CSS Tutorial<\/strong>, we will learn how to create shapes in CSS:&#x1f60e;<br>&#8211;  <a href=\"#create-heart-shape-in-css\">Create Heart Shape&nbsp;in CSS<\/a> <br>&#8211;  <a href=\"#create-triangle-shape-in-css\">Create Triangle Shape in CSS<\/a><br>&#8211;  <a href=\"#create-star-shape-in-css\">Create Star Shape in CSS <\/a><\/p>\n\n\n\n<p><strong>Chalo suru kiya jaye!<\/strong>&#x1f37b;<strong>&nbsp;Lets start!&nbsp;<\/strong>&#x1f57a;.<\/p>\n\n\n\n<h2>How to Create Shapes in CSS<\/h2>\n\n\n\n<p>Creating Shapes using CSS is mostly a trick to manipulate the HTML elments and render them as a shape.<\/p>\n\n\n\n<h2 id=\"create-heart-shape-in-css\">Create Heart Shape&nbsp;in CSS<\/h2>\n\n\n\n<p>This trick involves positioning of multiple elements.<br>Create a square and rotate it by 45degree.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img width=\"985\" height=\"387\" src=\"http:\/\/frontendguruji.com\/wp-content\/uploads\/2022\/02\/image-6.png\" alt=\"how to create shapes in css,create heart shape in css,create triangle shape in css,create star shape in css,css tutorial for beginners\" class=\"wp-image-494\" srcset=\"https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-6.png 985w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-6-300x118.png 300w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-6-768x302.png 768w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-6-150x59.png 150w\" sizes=\"(max-width: 985px) 100vw, 985px\" \/><\/figure>\n\n\n\n<p>Then use pseudo element :after to create a circle and push it out from left by 50%.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img width=\"1024\" height=\"464\" src=\"http:\/\/frontendguruji.com\/wp-content\/uploads\/2022\/02\/image-7.png\" alt=\"how to create shapes in css,create heart shape in css,create triangle shape in css,create star shape in css,css tutorial for beginners\" class=\"wp-image-495\" srcset=\"https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-7.png 1024w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-7-300x136.png 300w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-7-768x348.png 768w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-7-150x68.png 150w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p> Then use pseudo element :before to create a circle and push it out from top by 50%. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img width=\"1007\" height=\"441\" src=\"http:\/\/frontendguruji.com\/wp-content\/uploads\/2022\/02\/image-8.png\" alt=\"how to create shapes in css,create heart shape in css,create triangle shape in css,create star shape in css,css tutorial for beginners\" class=\"wp-image-496\" srcset=\"https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-8.png 1007w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-8-300x131.png 300w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-8-768x336.png 768w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-8-150x66.png 150w\" sizes=\"(max-width: 1007px) 100vw, 1007px\" \/><\/figure>\n\n\n\n<p>Tada! we got &#x1f497;.<\/p>\n\n\n\n<p> Link to CodePen sample: <a href=\"https:\/\/codepen.io\/mandeeppasbola\/pen\/LYOOzjM\" target=\"_blank\" rel=\"noreferrer noopener\">Create Heart &#x1f497; shape in CSS<\/a> <\/p>\n\n\n\n<h2 id=\"create-triangle-shape-in-css\">Create Triangle Shape in CSS<\/h2>\n\n\n\n<p>This trick involves border-radius of the element.<br>Define width and height of the element as 0. And then add color to one of the border and to rest add transparent color, to hide them.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"1024\" height=\"426\" src=\"http:\/\/frontendguruji.com\/wp-content\/uploads\/2022\/02\/image-9-1024x426.png\" alt=\"how to create shapes in css,create heart shape in css,create triangle shape in css,create star shape in css,css tutorial for beginners\" class=\"wp-image-497\" srcset=\"https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-9-1024x426.png 1024w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-9-300x125.png 300w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-9-768x320.png 768w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-9-150x62.png 150w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-9.png 1081w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Moving the border color will change the direction of the triangle.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"1024\" height=\"443\" src=\"http:\/\/frontendguruji.com\/wp-content\/uploads\/2022\/02\/image-10-1024x443.png\" alt=\"how to create shapes in css,create heart shape in css,create triangle shape in css,create star shape in css,css tutorial for beginners\" class=\"wp-image-498\" srcset=\"https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-10-1024x443.png 1024w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-10-300x130.png 300w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-10-768x332.png 768w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-10-150x65.png 150w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-10.png 1035w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p> Link to CodePen sample: <a href=\"https:\/\/codepen.io\/mandeeppasbola\/pen\/OJOOxQM\" target=\"_blank\" rel=\"noreferrer noopener\">Create Triangle &#x1f53a; shape in CSS<\/a> <\/p>\n\n\n\n<h2 id=\"create-star-shape-in-css\">Create Star Shape in CSS<\/h2>\n\n\n\n<p> This trick involves positioning of multiple elements.<br> Create a trianlge and rotate it by 35degree.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img src=\"http:\/\/frontendguruji.com\/wp-content\/uploads\/2022\/02\/image-1024x381.png\" alt=\"how to create shapes in css,create heart shape in css,create triangle shape in css,create star shape in css,css tutorial for beginners\" class=\"wp-image-488\" width=\"1024\" height=\"381\" srcset=\"https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-1024x381.png 1024w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-300x111.png 300w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-768x285.png 768w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-150x56.png 150w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image.png 1227w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Use pseudo element :before to create one more triangle and position it like below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"1024\" height=\"487\" src=\"http:\/\/frontendguruji.com\/wp-content\/uploads\/2022\/02\/image-3-1024x487.png\" alt=\"how to create shapes in css,create heart shape in css,create triangle shape in css,create star shape in css,css tutorial for beginners\" class=\"wp-image-491\" srcset=\"https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-3-1024x487.png 1024w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-3-300x143.png 300w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-3-768x365.png 768w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-3-150x71.png 150w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-3.png 1187w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p> Now use another pseudo element :after to create one more triangle and position it like below. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"1024\" height=\"483\" src=\"http:\/\/frontendguruji.com\/wp-content\/uploads\/2022\/02\/image-4-1024x483.png\" alt=\"how to create shapes in css,create heart shape in css,create triangle shape in css,create star shape in css,css tutorial for beginners\" class=\"wp-image-492\" srcset=\"https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-4-1024x483.png 1024w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-4-300x142.png 300w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-4-768x363.png 768w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-4-150x71.png 150w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2022\/02\/image-4.png 1165w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Tada! we got &#x2b50;<\/p>\n\n\n\n<p>Link to CodePen sample: <a href=\"https:\/\/codepen.io\/mandeeppasbola\/pen\/JjOOrdv\" target=\"_blank\" rel=\"noreferrer noopener\">Create Star&#x2b50; shape in CSS<\/a><\/p>\n\n\n\n<p>Thanks &#x1f64f;.<\/p>\n\n\n\n<p>Liked this tutorial? Check more here -&gt;&nbsp;<a href=\"http:\/\/frontendguruji.com\/tag\/css\/\">CSS Turorials<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this CSS Tutorial for Beginners, you will learn How to Create Shapes in CSS. Create Heart, Triangle &#038; Star shape\u00a0using HTML &#038; CSS.<\/p>\n","protected":false},"author":1,"featured_media":506,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[47],"tags":[12,48,7,49,50],"_links":{"self":[{"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/posts\/485"}],"collection":[{"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/comments?post=485"}],"version-history":[{"count":1,"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/posts\/485\/revisions"}],"predecessor-version":[{"id":617,"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/posts\/485\/revisions\/617"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/media\/506"}],"wp:attachment":[{"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/media?parent=485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/categories?post=485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/tags?post=485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}