Choose direction, size, and colour — get a live preview and copy the pure-CSS border-trick code instantly. No images, no SVG.
CSS Triangle Generator is a free, browser-based tool for creating pure-CSS triangles using the classic border trick. Select a direction from the 8-point compass grid, pick your size and colour, see an instant live preview on a checkerboard background, and copy the generated CSS rule in one click.
CSS triangles are used throughout web UIs: tooltip arrows, dropdown carets, decorative dividers, speech bubble tails, loading indicators, and navigation breadcrumb separators. Because they use only borders — no images, no SVG, no pseudo-element canvas — they scale perfectly, load instantly, and are fully customisable via CSS variables.
The checkerboard preview background (adapted from the pattern CSS uses to indicate transparency in image editors) makes it obvious which borders are structural-transparent vs. the visible coloured border that forms the triangle shape.
.triangle rule. Paste it into your stylesheet and apply the class to any empty <div>.A CSS triangle is created by setting an element to zero width and height, then exploiting how CSS renders borders. When an element has zero dimensions and multiple borders meet at a corner, each border is drawn as a trapezoid that fills the corner. When only one border is given a colour and the adjacent borders are transparent, that trapezoid becomes a triangle.
For a pointing-up triangle: the left and right borders are set to half the desired width each and coloured transparent. The bottom border is set to the full height and given the visible colour. The result is a triangle pointing upward.
For corner triangles (diagonal): only two adjacent borders are needed — one coloured, one transparent. Since there are only two borders, no "trapezoid averaging" occurs and the shape is a true right-angle triangle filling the corner of the box.
Width and height are computed like this:
border-left = border-right = width÷2, border-bottom/top = heightborder-top = border-bottom = height÷2, border-right/left = widthThese elements have zero width and height — so their invisible CSS box occupies no page space. This means you may need to position them with absolute/relative positioning or inline-block spacing depending on usage.
Let us know what's wrong with CSS Triangle Generator.
Thank you — report received!