Before generating a CSS triangle, compare the pointing direction, final visible width and height, solid fill color, surrounding background, decorative meaning, and required edge effects.
A CSS border triangle is not an ordinary box with a triangular background: the element's content width and height are both zero, while borders form the visible shape. That geometry makes direction, footprint, and context more important than a quick visual check. The CSS Triangle Generator supports the focused use case of a solid, straight-edged triangle and keeps the preview, CSS, and HTML synchronized.

The pre-generation comparison checklist
Resolve these decisions before producing code:
| Decision | What to compare | Why it changes the result |
|---|---|---|
| Pointing direction | Up, down, left, or right | The tip must align with the space, control, or adjacent content where the triangle will appear. |
| Visible footprint | The intended base, depth, and available room | Borders occupy painted space even though the element's content box is zero. |
| Fill and background | The solid color and the surface behind it | An opaque triangle can disappear against the wrong background or fail in another theme. |
| Meaning | Decoration versus state, direction, validation, or navigation | A decorative shape can be hidden from assistive technology, but a meaningful indicator also needs an accessible equivalent. |
| Shape complexity | A solid straight edge versus curves, a hollow center, a gradient, a stroke, or an arbitrary polygon | The border technique only handles simple solid triangles directly. |
| Destination behavior | Alignment, overflow, hit area, zoom, forced colors, and nearby themes | The live preview confirms border geometry, not the complete behavior of the final component. |
The footprint comparison needs direction-specific terms. For up- and down-facing triangles, width is the horizontal base and height is the vertical depth. For left- and right-facing triangles, height is the vertical base and width is the horizontal depth. The Choosing Width and Height in the CSS Triangle Generator guide explains that distinction further. The generator accepts whole dimensions from 10 through 300 pixels and a strict six-digit HEX color, so settle those values before generating.
Direction and painted dimensions
The generator writes each border longhand explicitly so the resulting geometry remains visible and auditable:
- Up: transparent left and right borders form the slopes, a colored bottom border creates the upward-pointing triangle, the selected width is the combined width of the two side borders, and the selected height is the bottom border width.
- Down: transparent left and right borders form the slopes, a colored top border creates the downward-pointing triangle, the selected width is the combined width of the two side borders, and the selected height is the top border width.
- Left: transparent top and bottom borders form the slopes, a colored right border creates the left-pointing triangle, the selected height is the combined height of the two horizontal borders, and the selected width is the right border width.
- Right: transparent top and bottom borders form the slopes, a colored left border creates the right-pointing triangle, the selected height is the combined height of the two horizontal borders, and the selected width is the left border width.
Compare the intended base and depth rather than assuming that the CSS width property always describes the triangle's base. The border allocation also explains why changing direction can alter how the same width and height values are used.
Even totals are split equally, while odd totals use floor and ceiling values to protect the requested painted size. For an up-facing triangle with a requested 41 px width, floor(41 ÷ 2) = 20 px and ceiling(41 ÷ 2) = 21 px; the transparent side borders therefore total 20 px + 21 px = 41 px. The colored bottom border still uses the selected height. This one-pixel asymmetry avoids silently losing part of the requested base during browser pixel quantization, although rasterization can still vary with zoom and device pixel ratio.
The MDN CSS backgrounds and borders guide documents the relevant border longhands and transparent color behavior, while the CSS Backgrounds and Borders Level 3 specification defines the associated widths, styles, and colors. These describe the underlying CSS mechanics; the generator's accepted dimension range and directional serialization are product-specific rules rather than universal triangle standards.
Generate and inspect the triangle
- Open the CSS Triangle Generator, choose the pointing direction, enter the whole-pixel width and height, and select the fill using a hash followed by exactly six hexadecimal digits. Confirm that the values match the footprint, color, and background decisions you made.
- Inspect the live result at the approximate size and background where it will be used. Check the tip direction, overall footprint, edge alignment, and visible color. The preview uses the same derived border declarations shown in the CSS output, so it is useful for checking geometry rather than judging the shape in isolation.
- Copy both the CSS and HTML. The two copy controls request clipboard permission separately, and a success message identifies the copied format. If browser policy denies clipboard access, both code blocks remain visible for manual selection instead of the page reporting a false success. The HTML consists of one div with the generated class and aria-hidden="true".
- Integrate the synchronized outputs into the destination, then test the assembled component. Keep the hidden treatment when the triangle is purely decorative. When it communicates information, provide visible text or an accessible label on the surrounding semantic control while keeping the decorative shape hidden from assistive technology. Check the final result at 200 percent zoom, in high-contrast and forced-colors modes, and at common mobile widths.
Generation and copying happen entirely in the current browser tab, with no upload, account, server rendering, or saved design state. The copied snippet contains no script, event handler, inline image, remote request, or dependency.
Accessibility and destination behavior
The generated aria-hidden="true" treatment is appropriate only for a decorative arrow or separator that conveys no information. A triangle that communicates state, direction, validation, navigation, or another meaning must not be the sole accessible indicator. Add visible text or an accessible label to the surrounding interactive control and keep the decorative triangle hidden.
Prefer one semantic control with a decorative shape over duplicated hidden controls. Also separate geometry from interaction: the triangle's measurable content box remains zero, so layout, transforms, hit testing, outlines, overflow, and alignment can behave less intuitively than expected. The preview confirms the border geometry, but it does not validate the accessibility or complete layout behavior of the destination component.
Match the technique to the shape
A border triangle is appropriate when the requirement is a compact, solid, straight-edged arrow or separator. Compare the requested design features before committing to this technique:
| Design requirement | Border-triangle fit | Decision |
|---|---|---|
| Solid triangle with straight edges | Supported directly | A border triangle is a suitable choice. |
| Rounded tip, curved edge, or hollow shape | Not supported | Use SVG or clip-path. |
| Gradient fill, stroke, or complex shadow | Not supported directly | Use SVG or a richer CSS approach. |
| Arbitrary polygon | Not supported | Use SVG or clip-path. |
| Highly precise transforms or hit behavior | Painted borders occupy space around a zero-size content box | Test the layout carefully or consider SVG with an explicit viewBox. |
For curves, strokes, gradients, complex shadows, or arbitrary geometry, use SVG or clip-path and test browser support in the intended environment. The generator itself does not rely on SVG, canvas, an image file, or a pseudo-element library; it produces a simple CSS border triangle and a single HTML div.
Color and production cleanup
Compare the literal fill color against the actual surrounding surface, including light and dark themes and forced-colors behavior. The generator requires a hash plus six hexadecimal digits, normalizes the color to lowercase, and paints it as an opaque border. Alpha colors, CSS variables, gradients, currentColor, wide-gamut syntax, and theme tokens are not generated by the focused tool.
After copying, replacing the literal color with a trusted design token can improve theming, but verify that the target syntax is supported and that the transparent side borders remain transparent. The How to Choose Color When Using a CSS Triangle Generator guide provides additional guidance for this comparison. Do not assume the triangle will inherit enough contrast from nearby text.
Before shipping, rename lizely-triangle if that class conflicts with an existing stylesheet, and update the CSS and HTML together. Keeping the class names synchronized prevents the copied HTML from losing its intended styling, while final accessibility, theme, zoom, and layout checks remain necessary in the page where the triangle is used.