A CSS border triangle is a zero-size element whose three thick borders meet at angles to paint a solid arrow. Each side of the triangle is a border: two transparent borders form the slopes and one colored border points in the chosen direction, which is why the visible shape exists even though the element itself has no width or height. The technique is famously fragile — a single pixel of width, an RGB value, an odd base dimension, or the wrong border colored can flatten the triangle, point it the wrong way, or silently shrink it by one pixel at certain zooms. Most of these mistakes share a single cause: a developer typing the CSS by hand instead of generating the synchronized CSS and HTML. A focused CSS Triangle Generator constrains inputs to integers between 10 and 300 pixels and a strict six-digit HEX color, then mirrors the exact border declarations into a live preview and matching code blocks so the geometry you see is the geometry you paste. That constraint layer turns a fragile one-line trick into a copyable recipe that you can audit line by line.

The Zero-Size Trick and Why It Breaks Easily
The single most common mistake is treating a CSS triangle like a normal shape. The element does not have width or height in the conventional sense; both content dimensions are explicitly set to zero, and the entire painted area comes from the borders. When a developer writes width: 80px; height: 80px; "to make the triangle the right size," the shape collapses into a tiny colored dot in the middle of an 80 pixel box, because the borders no longer reach across the full diagonal. The triangle's apparent size is governed entirely by border thickness, not by the element box.
A second beginner mistake is forgetting to set the two non-pointing borders to transparent. Without that, all four corners receive the colored border treatment and the result is four trapezoids meeting in a square — or, depending on which border is colored, a shape that does not look like a triangle at all. Hand-written CSS tends to use the shorthand border: 50px solid #ff8800 and then "fix" it by overriding one side, which leaves the others painted. The generator sidesteps this by writing every longhand border declaration explicitly, so the geometry is visible and auditable in the output.
Generate the Triangle in Five Steps
- Pick the triangle direction — up, down, left, or right — from the available options.
- Set the visible width and height as whole integers between 10 and 300 pixels; do not type decimals.
- Choose a six-digit HEX color such as #3366ff; named colors, RGB, HSL, alpha, and CSS variables are not generated by the tool.
- Inspect the live preview at the approximate size and background where the triangle will appear; the preview uses the same derived border declarations as the output.
- Click Copy CSS and Copy HTML separately, rename the lizely-triangle class if it would clash with an existing stylesheet, and update both blocks together.
Color and Direction Mistakes That Silently Break the Shape
A frequent mistake is to assume that the colored border is always the bottom border, or to copy a snippet written for one direction and forget to swap the colored side. The mapping is fixed and easy to get wrong by hand.
| Direction | Colored border | Transparent borders | Painted base |
|---|---|---|---|
| Up | Bottom | Left, Right | Selected height |
| Down | Top | Left, Right | Selected height |
| Left | Right | Top, Bottom | Selected width |
| Right | Left | Top, Bottom | Selected width |
For a vertical triangle (up or down), the two transparent side borders add up to the selected width, and the colored border equals the selected height. For a horizontal triangle (left or right), the transparent top and bottom borders add up to the selected height, and the colored border equals the selected width. Even dimensions split cleanly; odd dimensions do not, which is covered in the next section.
Color format mistakes are just as costly. The generator requires a hash plus exactly six hexadecimal digits and normalizes the value to lowercase. #FF8800, #ff8800, and f80 all look correct at a glance, but only the six-digit form passes the validator, and the tool will reject an unsupported format rather than silently clamp it. RGB, HSL, alpha channels, gradients, currentColor, and wide-gamut syntax are outside the tool's scope; if you need any of those, replace the literal with a trusted design token after copying, and confirm the transparent side borders remain transparent.
Dimension, Pixel Loss, and Class Name Pitfalls
The most subtle mistake is letting browser pixel quantization eat a pixel off the base. Chromium can quantize two borders of 20.5 pixels down to 20 pixels each, so a requested 41 pixel base silently renders as 40 pixels. A hand-written snippet rarely notices; the difference only shows up at specific zooms or device pixel ratios. The generator handles odd totals by splitting the perpendicular base into floor and ceiling values, for example 20px and 21px for a 41px base, so the requested painted dimension is preserved.
Worked example for a 41px wide upward triangle:
- Selected width: 41, selected height: 41, direction: up.
- Transparent left border: 20px, transparent right border: 21px (floor + ceiling of 41).
- Colored bottom border: 41px solid #3366ff.
- Resulting painted base: 20 + 21 = 41 pixels, matching the requested width.
Range and format mistakes follow a related pattern. Width and height accept whole values only, between 10 and 300 pixels inclusive; the browser controls prevent typing anything else, while the underlying generator independently rejects malformed input rather than quietly producing partial code. Decimal values like 41.5px, negative numbers, and out-of-range values are refused. If you need a triangle outside that range, the tool is not the right place to build it.
Class names cause the last common copy-and-paste mistake. The generator names the class lizely-triangle. If that name already exists in your stylesheet with different rules, the triangle will render with the wrong border declarations or inherit conflicting longhand overrides. The fix is mechanical: rename the class in both the CSS and HTML blocks together, then verify the new name does not collide with any other selector.
Accessibility, Clipboard, and What the Preview Does Not Verify
The HTML output contains one div with the generated class and aria-hidden="true". That choice is correct for a decorative arrow or separator that conveys no information to a screen reader. It is wrong for a triangle that communicates state, direction, validation feedback, navigation, or any other meaning. In those cases, add visible text or an accessible label to the surrounding interactive control, and keep the decorative triangle hidden from assistive technology. The generator cannot detect the semantic role of your component, so this decision belongs to you.
Copy CSS and Copy HTML each request clipboard permission separately. If a browser denies clipboard access, both code blocks remain visible for manual selection and the page does not falsely report a successful copy. Do not assume that a click on Copy equals a paste into your file — always confirm the clipboard contains the format you expected.
The live preview confirms border geometry; it does not confirm layout, alignment, hit testing, or contrast in a destination component. Rasterization of diagonal edges varies with zoom and device pixel ratio, and the painted border is fully opaque, so a triangle sitting next to text should be checked in both light and dark themes rather than assumed to inherit sufficient contrast. Verify the final result at 200 percent zoom, with high contrast enabled, and with forced colors active, on the screen widths your users actually use.
When a CSS Triangle Is the Wrong Choice
Border triangles are compact but limited. The measurable content box is zero while the painted borders occupy space, so layout, transforms, hit testing, outlines, overflow, and alignment can be less intuitive than an SVG with an explicit viewBox. A border triangle cannot directly create a rounded tip, a curved edge, a hollow shape, a gradient fill, a stroke, a complex shadow, or an arbitrary polygon. For those needs, use SVG or clip-path, and test browser support in the intended environment.
Performance is rarely a concern for a single triangle, but hundreds of decorative elements can noticeably increase DOM and paint work. Prefer one semantic control with a decorative shape over duplicated hidden controls, and reserve the tool for the four supported directions only — diagonal triangles are not generated here. If you need them, MDN's CSS backgrounds and borders guide documents the underlying border properties, and the CSS Backgrounds and Borders specification defines the longhand border widths, styles, and colors the generator builds on.