After reading through Smashing Magazine’s latest article, 50 New CSS Techniques For Your Next Web Design, I came across an article glossing over a technique for creating a triangle using pure CSS. A triangle using just CSS? That blew my mind! How is that even possible?
Note: As expected, Internet Explorer acts a bit wonky especially IE6. These experiments were done in Firefox 3.5 but you can see what they should look like in a screenshot I took.
Per the box model, the border outlines the perimeter of an element. When an element has a width and height of 0px the border-width’s make up the dimensions of the element.The corners of borders meet at a 45° angle which is apparent with larger border widths and what makes pure CSS shapes possible. The final CSS to make a 200 pixel tall red triangle pointing up looks like showing above..
.triangle { border-color: transparent transparent red transparent;border-style: solid; border-width: 0px 200px 200px 200px; height: 0px; width: 0px; }
.delicious { border-color:#FFFFFF #3274D0 #D3D2D2 #000000; border-style:dashed; border-width:150px; height:0; width:0; }


I found this article useful in a paper I am writing at university. Hopefully, I get an A+ now!
Thanks
Bernice Franklin
There is a one major problem with this article.
u can’t change the width of this triangles and shapes….
if u would like to change than u have to change border width…
thanks
great post as usual!
Wow this is a great resource.. I’m enjoying it.. good article
Keep up the good work, I like your writing.
Valuable info. Lucky me I found your site by accident, I bookmarked it.