Home › All Tools ›

CSS Triangle Generator

Use CSS Triangle Generator online for free at FreeToolZones — no sign-up, no watermark.

Loading tool...

The CSS Triangle Generator creates triangles using only CSS borders, with no image files, no SVG, and no extra markup beyond a single empty element. Triangles are small but hardworking shapes on the web: they point at tooltips, mark dropdown menus, form arrows and play buttons, and decorate section dividers. Building one by hand requires remembering which borders to make transparent and which to colour, and a single mistake produces a rectangle or a missing shape.

This tool removes that memorisation. Choose a direction, set the width and height, pick a colour, and the preview shows the triangle immediately. The CSS panel shows a .triangle rule built from the classic border technique, with the element sized to zero width and zero height and the visible side formed by a coloured border. Copy the rule, apply the class, and the triangle appears in your layout.

What Is the CSS Triangle Generator?

The CSS Triangle Generator is a visual editor for border-based CSS triangles. It works on a simple principle: when an element has zero width and zero height, its four borders meet as triangles at the centre. Making three borders transparent and one border solid leaves a single visible triangle pointing away from the coloured border. An upward-pointing triangle, for example, uses a coloured bottom border and transparent left and right borders.

The direction dropdown offers Up, Down, Left, and Right. The width slider runs from 10 to 300 pixels and the height slider from 10 to 300 pixels. For up and down triangles, the width is split equally between the two transparent side borders, and the height becomes the coloured border. For left and right triangles, the roles swap: the height is split between the transparent top and bottom borders, and the width becomes the coloured border. The colour picker sets the colour of the visible border.

The preview shows the triangle centred in the preview area, on a plain background, so the shape and proportions are easy to judge. The default triangle points up, is 120 pixels wide and 100 pixels tall, and uses a deep green colour. Changing the direction rewrites which borders are transparent and which are coloured, and changing the dimensions recalculates the border widths, including halved values where a dimension is split between two borders.

  • Four directions: Up, Down, Left, and Right, each with the correct border arrangement.
  • Width and height sliders: each from 10 to 300 pixels, controlling the triangle proportions.
  • Colour picker: a single colour for the visible triangle.
  • Border technique: zero-size element with transparent and coloured borders.
  • Centred preview: the triangle is shown on its own, without distractions.

How to Use the CSS Triangle Generator

Pick the direction first, because it determines which dimension controls the point and which controls the base.

  1. Choose the direction. Use the Direction dropdown to select Up, Down, Left, or Right. The triangle in the preview rotates to point in the chosen direction, and the CSS rewrites the border declarations to match.
  2. Set the width. Drag the Width slider between 10 and 300 pixels. For up and down triangles, this is the width of the base. For left and right triangles, this is the length from base to point.
  3. Set the height. Drag the Height slider between 10 and 300 pixels. For up and down triangles, this is the length from base to point. For left and right triangles, this is the height of the base.
  4. Pick the colour. Use the Color picker to choose the triangle colour. The colour should match or complement the element the triangle points at, such as a tooltip box or a menu panel.
  5. Check the proportions. Look at the preview as a whole. A wide base with a short height gives a flat triangle, while a narrow base with a tall height gives a sharp spike. Adjust until the shape suits its purpose.
  6. Read the generated CSS. Look at the .triangle rule in the CSS panel. Notice which borders are transparent and which carry the colour, and how the split dimensions appear as halved border widths.
  7. Copy the CSS. Click Copy CSS and paste the rule into your stylesheet. Apply the triangle class to an empty element, or rename the class to match your markup.

Key Features of the CSS Triangle Generator

The tool encodes the border-triangle pattern correctly for all four directions, so you never need to work out the transparent borders yourself.

  • Correct border logic: each direction uses the right combination of transparent side borders and one coloured border, with no leftover borders from a previous direction.
  • Automatic halving: dimensions split between two borders are halved automatically, including fractional results when the width or height is odd.
  • Wide size range: dimensions up to 300 pixels cover small indicators, large decorative dividers, and everything between.
  • Single-colour output: the triangle is one flat colour, which keeps the code short and the shape crisp at any size.
  • Zero-size element: the rule sets width and height to zero, which is the foundation of the border technique and keeps the element from taking up extra space.
  • Instant direction switching: changing direction updates the preview and the CSS together, making it easy to compare orientations.

Practical Use Cases

Triangles are most useful as pointers and indicators. The examples below show the jobs where a CSS triangle is the simplest solution.

Tooltip pointers

A tooltip box usually has a small triangle on one edge pointing at the element it describes. A triangle of 12 to 20 pixels, in the same colour as the tooltip background, creates that pointer without an image. Position the triangle with your own layout code so it overlaps the tooltip edge.

Dropdown and accordion indicators

A small down triangle beside a menu label signals that more content will appear, and an up triangle signals that content can be collapsed. Triangles of 8 to 12 pixels work well for these indicators, because they must stay subtle next to the label text.

Play buttons and media controls

A right-pointing triangle is the universal play symbol. A larger triangle, perhaps 40 to 60 pixels wide, inside a circle or on its own, makes a recognisable play button for video thumbnails and audio players, with no image asset to load.

Section dividers and ribbons

Large triangles can form decorative edges between sections, chevron dividers, or ribbon ends. Because the triangle is pure CSS, it scales cleanly and matches the section colours exactly, without the banding or compression artefacts of an image.

Chat bubbles and callouts

Chat messages and callout boxes often have a small triangle tail pointing toward the speaker or the referenced element. A left or right triangle in the bubble colour, positioned at the edge of the box, creates that tail with minimal code.

Tips and Best Practices

Triangles are simple shapes, but their placement needs care. These practices keep them looking intentional.

  • Match the target colour exactly: a tooltip pointer that is even slightly different from the tooltip box looks like a mistake. Use the same colour value for both.
  • Keep indicators small: a dropdown arrow should be smaller than the text beside it. If the triangle competes with the label, reduce its size.
  • Position with your own code: this tool generates the shape only. Use absolute positioning, margins, or a pseudo-element in your stylesheet to place the triangle against its target element.
  • Test at the real size: a triangle that looks balanced at 120 pixels may look chunky at 12 pixels. Check the smallest size you will actually use.
  • Consider accessibility: a triangle used as the only indicator of state, such as an open menu, should be paired with text or an accessible label in your markup, because the shape alone conveys nothing to assistive technology.
  • Prefer CSS over images for simple shapes: a border triangle loads instantly, scales without blur, and changes colour with one value. Reserve images for shapes that CSS cannot draw.

Limitations

This generator creates solid triangles in a single colour, using the border technique only. It does not support outlined triangles, triangles with rounded corners, triangles with gradients or shadows, right-angled triangles, or triangles with borders of different widths on each side. The element has zero width and zero height, so it cannot contain text or other content, and it cannot be given a background colour that would show.

The output is the shape rule only. It does not include positioning, so the triangle will appear in the normal flow of your document unless you position it yourself. On very high-resolution displays, the diagonal edges of a border triangle can look slightly stepped, which is a known characteristic of the technique. For pixel-perfect shapes at large sizes, an SVG may be a better choice.

  • Solid single-colour triangles only; no outlines, gradients, or shadows.
  • Four cardinal directions only; no diagonal or right-angled triangles.
  • Zero-size element; cannot contain content.
  • No positioning included; you place the triangle yourself.

Frequently Asked Questions

How does a triangle appear from borders?

When an element has zero width and zero height, its four borders meet at angles in the centre, each forming a triangle. Colouring one border and making the other three transparent leaves only one triangle visible. The coloured border is opposite the direction the triangle points.

Why are some border widths halved in the output?

For an up or down triangle, the base width is split equally between the left and right transparent borders, so each is half the width. For a left or right triangle, the base height is split equally between the top and bottom borders. Halving keeps the triangle symmetrical.

Can I put text inside the triangle?

No. The triangle element has zero width and zero height, so it has no interior space for content. If you need a labelled shape, place the triangle beside or behind a separate element that holds the text, using positioning in your own stylesheet.

How do I attach the triangle to a tooltip or a box?

Position the triangle element against the edge of the box using absolute positioning or a pseudo-element in your own CSS, and give it the same colour as the box. The generator produces the shape; the placement depends on your layout and must be written for your specific markup.

Will the triangle look sharp on all screens?

Border triangles are crisp at small and medium sizes. At very large sizes, the diagonal edges can show slight stepping on some displays, because the shape is drawn from borders rather than vector paths. For large decorative shapes where perfect edges matter, consider an SVG instead.

Border Triangles Versus Modern Alternatives

The border technique for triangles dates from an era when CSS had few shape tools, and it survives because it is simple, reliable, and dependency-free. Modern CSS offers alternatives, notably clip-path, which can draw a triangle and many other shapes with explicit coordinates, and SVG, which can draw any shape with perfect edges at any size. Each approach has a place, and choosing between them depends on the size of the shape, the need for precision, and the complexity of the design.

Border triangles win for small indicators: dropdown arrows, tooltip pointers, and play icons under about 60 pixels. At those sizes, the border technique is short, well understood, and crisp enough, and it requires no extra markup beyond a single element. Clip-path wins when the shape is part of a larger design system of clipped elements, or when the triangle needs to contain an image or a gradient, because clipping cuts the element content to the shape rather than building the shape from borders. SVG wins for large decorative shapes, icons that must be pixel-perfect, and shapes with strokes, gradients, or multiple colours, where the border technique cannot reach.

The practical lesson is to match the tool to the job rather than to habit. If you find yourself fighting the border technique, adding wrappers, pseudo-elements, and positioning hacks to achieve a shape that clip-path or SVG would express directly, switch approaches. Conversely, if a simple border triangle does the job, there is no need to introduce an SVG file for a twelve-pixel arrow. The CSS Triangle Generator exists for the first case: quick, correct, small triangles with no overhead, generated in seconds and pasted into any stylesheet.

Related Tools

These tools cover tooltips, shapes, and positioning-adjacent styling.

Browse More Tools