Arrows are widely used in modern websites. These are mainly used for sliding images and change pages. Although there are many icons available for these arrows. Sometimes you need to design a custom image depending on the client’s requirement. Creating arrows using CSS has many benefits such as they do not affect the page loading time, also very beneficial for SEO providing custom touch to the website.
Approach: Creating an arrow using CSS is very simple. First, create an L(alphabet) shape using some box-shadow property and then rotate it to some angle to align them (both left and right arrows) together.
HTML Code: In this section, two div elements are created, one for each arrow.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content= "width=device-width, initial-scale=1.0" /> <title>Arrow</title> </head> <body> <div class="left"></div> <div class="right"></div> </body> </html> |
CSS Code:
- Step 1: First use box-shadow property to make the div element as L-shaped.
- Step 2: Now rotate both of them at 45deg and -135deg angles to align them just opposite of each other.
Note: You can use some other values for the right arrow such as 225deg. You can find the perfect value of def using the developers console. You can also add hover effects depending on the requirement.
<style> body { padding: 280px 0 0 500px; background: green; } .left, .right { width: 100px; height: 100px; transition: .5s; float: left; box-shadow: -2px 2px 0 black; } .left { transform: rotate(45deg); } .right { transform: rotate(-135deg); } </style> |
Complete Code: It is the combination of the above two sections of codes.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content= "width=device-width, initial-scale=1.0" /> <title>Arrow</title> <style> body { padding: 280px 0 0 500px; background: green; } .left, .right { width: 100px; height: 100px; transition: .5s; float: left; box-shadow: -2px 2px 0 black; } .left { transform: rotate(45deg); } .right { transform: rotate(-135deg); } </style> </head> <body> <div class="left"></div> <div class="right"></div> </body> </html> |
Output:

Recommended Posts:
- How to Create Custom Radio Button using HTML and CSS ?
- Create a Website Alarm Using Python
- How to create a responsive Modal Sign-Up form for a Website?
- How to Create Dark/Light Mode for Website using JavaScript/jQuery?
- How to create responsive website zoomed out to full width on mobile using Bootstrap?
- How to create a custom callback in JavaScript?
- How to create custom banner background using CSS ?
- How to Create Custom Shape Button using SVG ?
- How to Create a Custom Image Magnifier using jQuery ?
- Service Worker | How to create custom offline page ?
- HTML Course | Building Header of the Website
- Introduction to HTML CSS | Learn to Design your First Website in Just 1 Week
- How to create a progress bar using HTML and CSS?
- How to create three boxes in the same div using HTML and CSS ?
- Create a Search Bar using HTML and CSS
- How to create a Pie Chart using HTML & CSS ?
- How to Create Breadcrumbs using HTML and CSS ?
- How to create Animated bars using HTML and CSS?
- How to Create a Transparent button using HTML and CSS ?
- How to Create ToDo App using HTML, CSS, JS and Bootstrap ?
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.


