
- CSS - Home
- CSS - Roadmap
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Types
- CSS - Measurement Units
- CSS - Selectors
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Border Block
- CSS - Border Inline
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursor
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS - Inline Block
- CSS - Dropdowns
- CSS - Visibility
- CSS - Overflow
- CSS - Clearfix
- CSS - Float
- CSS - Arrows
- CSS - Resize
- CSS - Quotes
- CSS - Order
- CSS - Position
- CSS - Hyphens
- CSS - Hover
- CSS - Display
- CSS - Focus
- CSS - Zoom
- CSS - Translate
- CSS - Height
- CSS - Hyphenate Character
- CSS - Width
- CSS - Opacity
- CSS - Z-Index
- CSS - Bottom
- CSS - Navbar
- CSS - Overlay
- CSS - Forms
- CSS - Align
- CSS - Icons
- CSS - Image Gallery
- CSS - Comments
- CSS - Loaders
- CSS - Attr Selectors
- CSS - Combinators
- CSS - Root
- CSS - Box Model
- CSS - Counters
- CSS - Clip
- CSS - Writing Mode
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - Pointer Events
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS - Cascading
- CSS - Universal Selectors
- CSS - ID Selectors
- CSS - Group Selectors
- CSS - Class Selectors
- CSS - Child Selectors
- CSS - Element Selectors
- CSS - Descendant Selectors
- CSS - General Sibling Selectors
- CSS - Adjacent Sibling Selectors
- CSS Advanced
- CSS - Grid
- CSS - Grid Layout
- CSS - Flexbox
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Paged Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS - Image Sprites
- CSS - Important
- CSS - Data Types
- CSS3 Advanced Features
- CSS - Rounded Corner
- CSS - Border Images
- CSS - Multi Background
- CSS - Color
- CSS - Gradients
- CSS - Box Shadow
- CSS - Box Decoration Break
- CSS - Caret Color
- CSS - Text Shadow
- CSS - Text
- CSS - 2d transform
- CSS - 3d transform
- CSS - Transition
- CSS - Animation
- CSS - Multi columns
- CSS - Box Sizing
- CSS - Tooltips
- CSS - Buttons
- CSS - Pagination
- CSS - Variables
- CSS - Media Queries
- CSS - Functions
- CSS - Math Functions
- CSS - Masking
- CSS - Shapes
- CSS - Style Images
- CSS - Specificity
- CSS - Custom Properties
- CSS Responsive
- CSS RWD - Introduction
- CSS RWD - Viewport
- CSS RWD - Grid View
- CSS RWD - Media Queries
- CSS RWD - Images
- CSS RWD - Videos
- CSS RWD - Frameworks
- CSS References
- CSS Interview Questions
- CSS Online Quiz
- CSS Online Test
- CSS Mock Test
- CSS - Quick Guide
- CSS - Cheatsheet
- CSS - Properties References
- CSS - Functions References
- CSS - Color References
- CSS - Web Browser References
- CSS - Web Safe Fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS - Arrows
CSS arrows are graphical symbols created using CSS properties, used to point the viewers attention in a specific direction. Arrows in CSS created using techniques like borders, clip paths, or icons. In this tutorial we will explore all the ways to create and style arrows in CSS.
Table of Contents
How to Create Arrows in CSS?
Arrows can be created using CSS properties as listed below:
- Using CSS Border: You can create an arrow in CSS by defining a square element and setting two of it's adjacent borders as transparent and other two borders visible.
- Using Icons: You can use predefined arrow icons defined in libraries like Font Awesome, Material Icons, and Google Icons. They often come with ready-to-use classes or utility classes.
- Using Clip Path: The clip-path property in CSS is used to define polygon of any shape, with this you can also define arrows of any shape.
- Using Unicode Characters: For creating simple arrows, you can specify unicode characters inside containers like div, For example the code '▶' will make a right-pointing arrow.
CSS Arrow Using Border
The borders is the most common way to create arrows. With borders we can create two types of arrows,
- For solid arrow, Set height and width of container element to zero. Then pick any border (for example, border-bottom) set a solid color and thickness as per size of arrow. Now give same thickness and but a transparent color to two adjacent borders of it ( In this case border-left and border-right). This will create a arrow pointing upwards.
- For line arrow, Set a height and width for element depending upon size of arrow needed. Now set thickness and color for any two adjacent borders (for example border-left and border-top). Rotate element to required direction using transform property.
Example
<!DOCTYPE html> <html> <head> <style> .arrow-up { width: 0; height: 0; border-left: 10px solid transparent; border-right: 10px solid transparent; border-bottom: 10px solid black; } .arrow-down{ width: 10px; height: 10px; border-left: 2px solid; border-top: 2px solid; transform: rotate(225deg) skew(10deg, 10deg); } .arrow-diagonal{ width: 10px; height: 10px; border-left: 2px solid; border-top: 2px solid; transform: rotate(90deg) skew(10deg, 10deg); } </style> </head> <body> <h3>Arrow Type 1</h3> <div class="arrow-up"></div> <h3>Arrow Type 2</h3> <div class="arrow-down"></div> <h3>Arrow Rotated</h3> <div class="arrow-diagonal"></div> </body> </html>
CSS Arrows Using Icons
We can also create arrows using predefined icon libraries like Font Awesome, Material Icons, and Google Icons. Following example uses google icons to display arrows.
Example
<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> </head> <body> <h1> Google Fonts Icon </h1> <span class="material-icons" style="font-size:40px;"> arrow_forward </span> <span class="material-icons" style="font-size:40px;"> arrow_backward </span> </body> </html>
Arrows Using Clip Path Property
We can create arrows of any shape using clip-path property in CSS.
clip-path: polygon(x1 y1, x2 y2, x3 y3, ...);
- x1 y1, x2 y2, ... are pairs of coordinates that define the vertices of the polygon. The coordinates are given as percentages or absolute units (e.g., px).
- The origin (0, 0) is the top-left corner of the element, and (100%, 100%) is the bottom-right corner.
Example
<!DOCTYPE html> <html> <head> <style> .arrow-right { width: 0; height: 0; margin: 29px; border-style: solid; border-width: 10px 0 10px 20px; clip-path: polygon(100% 50%, 0 100%, 0 0); } </style> </head> <body> <h3> Arrow Using Clip Path </h3> <div class="arrow-right" ></div> </body> </html>
CSS Arrows Styling
The following example shows how to style an arrow in css by setting properties like color, transform-rotate, shadow and animations.
Example
<!DOCTYPE html> <html lang="en"> <head> <style> .arrow { width: 0; height: 0; margin: 20px; } .arrow-color { border-left: 10px solid transparent; border-right: 10px solid transparent; border-bottom: 10px solid red; } .arrow-shadow { width: 20px; height: 20px; border-left: 2px solid; border-top: 2px solid; transform: rotate(135deg) skew(10deg, 10deg); box-shadow: -5px -5px 10px rgba(0, 0, 0, 0.5); } .arrow-rotated { border-left: 10px solid transparent; border-right: 10px solid transparent; border-bottom: 10px solid black; transform: rotate(45deg); } .arrow-animate { border-left: 10px solid transparent; border-right: 10px solid transparent; border-bottom: 10px solid aqua; transition: transform 0.3s ease-in-out; } .arrow-animate:hover { transform: translateY(-10px); } </style> </head> <body> <h3>Colored Arrow</h3> <div class="arrow arrow-color"></div> <h3> Arrow with shadow </h3> <div class="arrow arrow-shadow"></div> <h3> Rotated arrow </h3> <div class="arrow arrow-rotated"></div> <h3> Animated arrow </h3> <div class="arrow arrow-animate"></div> </body> </html>
CSS Tooltip Arrow
We can create a tooltip with an upward-pointing triangular arrow using CSS borders and transform property. We have used hover pseudo-class to make tooltip visible when user hovered over content.
Example
<!DOCTYPE html> <html> <head> <style> .tooltip { position: relative; display: inline-block; cursor: pointer; } .tooltipContent { display: none; position: absolute; background-color: grey; color: #fff; padding: 8px; border-radius: 4px; z-index: 1; font-size: 14px; white-space: nowrap; } .tooltip:hover .tooltipContent { display: block; } .tooltipContent::before { content: ""; position: absolute; border-width: 6px; border-style: solid; border-color: transparent transparent grey transparent; top: -12px; left: 50%; transform: translateX(-50%); } </style> </head> <body> <h3 class="tooltip"> Hover Me!!! <span class="tooltipContent">CSS - Arrow</span> </h3> </body> </html>