Create a Simple Ribbon With CSS

Introduction

 
In this example, we will create a simple Ribbon using CSS. 
 
RibbonCSS1.jpg
 
Step 1: First we will create the main div, in which the ribbon will appear:
  1. <div class="main"></div>.main {  
  2.     margin: 0px auto;  
  3.     width: 400px;  
  4.     background-image: url('wooden2.jpg');  
  5.     -moz-border-radius: 10px;  
  6.     -khtml-border-radius: 10px;  
  7.     -webkit-border-radius: 10px;  
  8.     position: relative;  
  9.     z-index: 80;  

Here we set the background of the div and rounded corner using the radius property and set the z-index property (this property is useful to display the div under the ribbon).
 
Step 2: Now we will create a ribbon using the <div> tag like this:
  1. <div class="main">  
  2. <div class="ribbon"><h2 align="center" style="color:Tan;">CSS</h2></div>  
  3. <div class="ribbon-left"></div>  
  4. <div class="ribbon-right"></div>  
  5. <div style="padding: 60px 25px 35px 25px;Color:wheat;">  
  6. <div > 
Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation semantics (the look and formatting) of a document written in a markup language. Its most common application is to style web pages written in HTML and XHTML, but the language can also be applied to any kind of XML document, including plain XML, SVG, and XUL. From Wikipedia</p>
 
Here we will specify three div elements (the first one shows the front part of the ribbon, the second will show the left part and the third will show the right part of the ribbon).
 
First, we will set the property of the front part of the ribbon:
  1. <div class="ribbon"><h2 align="center"style="color:Tan;">CSS</h2></div>.ribbon {  
  2.   background-imageurl('wooden1.jpg');  
  3.   height50px;  
  4.   
  5.   width430px;  
  6.   -moz-border-radius: 2px;  
  7.   -moz-border-radius: 2px;  
  8.   -khtml-border-radius: 2px;  
  9.   -webkit-border-radius: 2px;  
  10.   positionrelative;  
  11.   left: -15px;  
  12.   top: 40px;  
  13.   floatleft;  
  14.   z-index100;  

Here we will set the background Image, radius just like our main div, and set the z-index property to 100 (Note that the z-index property of the main div is 80) so the main div will appear under the ribbon.
 
Now we will write the code for the left and right part of the ribbon:
  1. .ribbon-left {  
  2.     border-colortransparent #FF9966 transparent transparent;  
  3.     border-stylesolid;  
  4.     border-width15px;  
  5.     background-imageurl('wooden1.jpg');  
  6.     height0px;  
  7.     width0px;  
  8.     positionrelative;  
  9.     left: -30px;  
  10.     top: 65px;  
  11.     z-index-1;  
  12. }  
  13.   
  14. .ribbon-right {  
  15.     border-colortransparent transparent transparent #FF9966;  
  16.     border-stylesolid;  
  17.     background-imageurl('wooden1.jpg');  
  18.     border-width15px;  
  19.     height0px;  
  20.     width0px;  
  21.     positionrelative;  
  22.     left: 400px;  
  23.     top: 35px;  
  24.     z-index-1;  

Here we will set the z-index property to -1. So they will appear under the div. Here we will also set the left and top position of the div. Which will be helpful to show that part under the main div.