What many people don’t know is that when you are drawing borders in CSS you are actually drawing triangles. Four triangles each represent one border of a box. With coloring one border and setting the others to transparent, you can create a singular triangle.
As you can see in the box below, we have four triangles in different colors.
border-color: red green blue yellow;
border-style: solid;
border-width: 20px;
height: 0px;
width: 0px;
When creating the singular triangle we set a color on one border and the rest transparent. It is done easily yet this is a technique that not many know.
border-color: transparent transparent blue transparent;
We set the border style to solid but when you change this style you will get different results, some examples:
border-style: dotted;
border-style: inset;
border-style: outset;
border-style: double;
Will says
Great work–this really helped me out!
ron says
Thank you for this great website! The first example on this page (http://css3-tutorial.com/creating-triangles-with-css) has typo in the CSS @ [widht: 0px;] which should be “WIDTH”
thanks again,
Ron
admin says
Thanks for pointing out the error and the kind words!
Mansingh Chaudhary says
thank you for great solution.