CSS - (Caret|Arrow)


A carret/Arrow is made in CSS with the help of the border corner.

The following ingredients are needed:

  • a block box
  • with a height and width of null
  • and transparent border

The width of the border becomes the width of the caret.


With width and weight → box

With width and weight, you get a box where you can already seen in the corners the beginning of an arrow.

.coloredBox {
	width: 20px; 
	height: 20px; 
	border-left: 4px solid aqua;
	border-right: 4px solid red;
	border-bottom: 4px solid black;
	border-top: 4px solid blue;
  • The type of block is important. It must be block box
<p>A block box</p>
<span class="coloredBox"></span>

<p>A inline box will not respond to the width</p>
<span class="coloredBox" style="display:inline"></span>

The p element renders by default as a block box whereas the span element renders default as a inline box

Without width and height → arrow


.caret-up {
	width: 0; 
	height: 0; 
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	border-bottom: 4px solid black;
<span class="caret-up"></span>


.caret-down {
	width: 0; 
	height: 0; 
	border-left: 6px solid transparent;
	border-right: 6px solid transparent;
	border-top: 6px solid blue; 
<p class="caret-down"></p>


.caret-right {
	width: 0; 
	height: 0; 
	border-top: 8px solid transparent;
	border-bottom: 8px solid transparent;
	border-left: 8px solid aqua;
<p class="caret-right"></p>


.caret-left {
	width: 0; 
	height: 0; 
	border-top: 10px solid transparent;
	border-bottom: 10px solid transparent; 
	border-right: 10px solid red; 
<p class="caret-left"></p>

Documentation / Reference

Discover More
HTML - Menu / Toolbar (list of commands)

menu is an element that can be used as an alternative to ul (list) to express an unordered list of commands creating a Menu (toolbar). ...

Share this page:
Follow us:
Task Runner