Updated · Built and checked by the PlinzoTools team, formulas tested against published sources
Generate a pure-CSS triangle using the border trick, any direction.
width: 0;
height: 0;
border-left: 40px solid transparent;
border-right: 40px solid transparent;
border-bottom: 40px solid #1565C0;This tool generates a pure-CSS triangle using the classic "border trick": a zero-width, zero-height element with one solid border side and two transparent sides, which browsers render as a triangle. No image or SVG file needed.
Set a size, color, and direction (up, down, left, or right). The preview and generated CSS update instantly.
A zero-size element's borders meet at 45-degree angled corners. By making the element's width and height zero, then coloring only one border side while leaving the adjacent two transparent, only that one colored triangular border segment remains visible -- producing a triangle shape with no actual content area.
For rounded shapes instead, see the Border Radius Generator.
The tool outputs a block with width: 0; and height: 0; followed by three border lines. For the default settings (size 40, color #1565C0, direction up), the block is: border-left 40px solid transparent, border-right 40px solid transparent and border-bottom 40px solid #1565C0. Notice what the size number really means: it is used as the width of each side border and the thickness of the colored border, not the width of the whole triangle.
With a size of 40 and direction up, the two transparent side borders are 40 pixels each, so the triangle's full base is 80 pixels wide, and its height is 40 pixels. The result is a triangle twice as wide as it is tall, with the point centered at the top. The same holds for the down direction. For left and right, the roles are swapped: the top and bottom borders are transparent and the colored border is on the right (for left) or left (for right), so the triangle is 40 pixels wide and 80 pixels tall. Knowing this helps you plan space: if a dropdown caret needs to sit in a 20 pixel tall row, a size of 10 gives a 20 pixel wide, 10 pixel tall pointer.
Pixel sizes are fixed. If your design scales with text, you can change the pixel numbers in the output to em values, so that the triangle grows and shrinks with the font size of its container. That is convenient for carets next to labels of different sizes.
Because CSS renders an element's 4 borders as trapezoids meeting at 45-degree diagonal seams at the corners -- shrinking the element to zero size collapses those trapezoids into triangles meeting at a point, and hiding 2 of the 4 leaves one visible triangle.
SVG offers more flexibility (non-equilateral triangles, gradients, strokes) but for a simple solid-color triangle, the CSS border trick needs zero extra markup or files, which is often simpler for small UI accents.
Not with this exact technique -- the border trick only produces triangles pointing up, down, left, or right; a diagonal-pointing triangle would need CSS transform: rotate() or an SVG/clip-path approach instead.
The size is applied to both transparent side borders, so the base is two times the size while the height equals the size. Halve your size value to fit a narrower space.
Not in a useful way. The element has no content area because its width and height are zero, so text would overflow. Place text in a separate element positioned over it.
Add a hover rule that changes the colored border line, for example the bottom border color for an up-pointing triangle, and keep the transparent sides unchanged.
Clip-path offers flexible shapes and works on elements with content, while the border approach is compact and simple. Choose based on whether you need custom proportions or just a quick pointer.
Reference: MDN Web Docs