CSS Triangles: The Border Trick vs clip-path, Explained With Tooltips
Tooltips, dropdown menus, speech bubbles and breadcrumb steps all need a small pointer. For more than twenty years, the standard way to draw one has been a CSS curiosity: an element with no width and no height, made entirely of borders. It looks like a hack, and it is one, but it’s a reliable and well-understood one. Modern CSS also offers cleaner alternatives.
Why borders make triangles
Give a box thick borders in four different colors and look closely at the corners: the borders meet at a diagonal line. That diagonal is how browsers join two borders of different colors.
Now shrink the box’s width and height to zero. With no content area left, each border becomes a triangle pointing toward the center. Make three of them transparent, and a single colored triangle remains.
.arrow-up {
width: 0;
height: 0;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 10px solid #141414;
}This triangle points up, because the visible border is the bottom one. The left and right transparent borders set the width (8 + 8 = 16px), and the bottom border sets the height (10px).
The eight directions
| Direction | Visible border | Transparent borders |
|---|---|---|
| Up | bottom | left and right (half width each) |
| Down | top | left and right |
| Left | right | top and bottom (half height each) |
| Right | left | top and bottom |
| Top-left | top | right (full width) |
| Top-right | top | left |
| Bottom-left | bottom | right |
| Bottom-right | bottom | left |
The corner triangles (right-angled) need only two borders. The CSS triangle generator above builds all eight and gives you the matching clip-path version too.
The clip-path alternative
.arrow-up {
width: 16px;
height: 10px;
background: #141414;
clip-path: polygon(50% 0, 100% 100%, 0 100%);
}This reads more naturally: a 16×10 box, cut into a triangle. Because it uses a background, it can be a gradient or an image.
| Aspect | Border triangle | clip-path triangle | Inline SVG |
|---|---|---|---|
| Readability | Low, needs explanation | High | High |
| Gradient fill | No | Yes | Yes |
| Border/outline on the triangle | Needs a second triangle | Needs a second shape | Native stroke |
| Shadow | filter: drop-shadow() works | Clipped; needs a wrapper | Works |
| Browser support | Every browser ever | All modern browsers | All browsers |
| Extra markup | None (pseudo-element) | None (pseudo-element) | SVG element |
For a tiny tooltip pointer, the border method and clip-path are equally good. For anything with a gradient, use clip-path. For icons, use SVG.
Building a tooltip arrow
The pointer belongs in a pseudo-element, so you don’t add markup:
.tooltip { position: relative; background: #141414; color: #fff; padding: 8px 12px; border-radius: 8px; }
.tooltip::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
transform: translateX(-50%);
border: 6px solid transparent;
border-top-color: #141414;
}This creates a downward pointer centered under the tooltip. Using border: 6px solid transparent and then coloring only one side is a compact way to write a triangle.
Arrows with borders
If your tooltip has a 1px border, the pointer needs one too. Stack two triangles: a slightly larger one in the border color using ::before, and the fill-colored one on top with ::after, offset by 1px. Alternatively, use a rotated square: a small square with the same background and border as the tooltip, rotated 45° and half-hidden behind the tooltip body. Rotated squares also take shadows nicely.
Dropdown carets and chevrons
A select-style caret (▼) can be a small border triangle, but many designs now use a chevron (an open “V”). Draw a chevron with a square that has only two borders, rotated 45°:
.chevron { width: 8px; height: 8px; border-right: 2px solid; border-bottom: 2px solid; transform: rotate(45deg); }Rotating it to -135deg when the menu opens makes a smooth open/close indicator. Using currentColor (the default border color) means the chevron automatically matches the text color.
Speech bubbles and breadcrumbs
- Speech bubbles: a rounded box plus a triangular tail from a pseudo-element, or a single clip-path polygon that includes the tail, which our clip-path guide covers.
- Arrow breadcrumbs: each step uses a right-pointing triangle on its right edge and a matching notch on its left. clip-path makes this a single polygon per step:
polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%).
Screen readers and forced-colors mode
Decorative arrows should be invisible to assistive technology. Pseudo-elements with empty content aren’t announced, which is ideal. If you use an element or an SVG, add aria-hidden="true".
Also check that pointers stay visible in Windows High Contrast (forced colors) mode, which overrides colors. Border-based triangles are drawn in system colors there and usually stay visible; clip-path shapes with backgrounds may disappear because backgrounds are removed. For important direction indicators, border triangles or SVG icons are the more robust choice.
Sizing guidelines
| Use | Typical size |
|---|---|
| Tooltip pointer | 10–14px wide, 6–8px tall |
| Dropdown caret | 8–10px wide |
| Speech bubble tail | 16–24px |
| Breadcrumb arrow | Matches the step height, about 10–14px deep |
Pointers that are too large look clumsy and draw attention away from the content they point to.