How to Create a Modern Ribbon Banner Navigation Bar with Pure HTML/CSS3 (2023)

How to Create a Modern Ribbon Banner Navigation Bar with Pure HTML/CSS3 (1) Sarah Kahn

Read Time: 7 min

Site ElementsCSSHTML

How to Create a Modern Ribbon Banner Navigation Bar with Pure HTML/CSS3 (2)How to Create a Modern Ribbon Banner Navigation Bar with Pure HTML/CSS3 (3)How to Create a Modern Ribbon Banner Navigation Bar with Pure HTML/CSS3 (4)

As CSS3 becomes more robust and is more widely supported, the options for fun modern design elements that can be created without graphics are virtually limitless! For a recent project, I decided to see if I could create a centered ribbon banner with pure CSS3. This tutorial will walk you through how it was done.

As it turns out, it’s actually quite easy, using only simple, semantic HTML and some CSS3 trickery thanks to the magic of the the border-width property. The only caveat: As with all new CSS3 techniques, it can act a bit wonky in some IE browsers... we'll address that at the end of the tutorial.

Here’s how:

Step 01: The Navigation Links

We want to create a navigation link bar, so we’re going to begin with a simple unordered list [ul] with links inside [a]. This is one of the most basic building blocks of markup; good for creating lists of elements to be styled in a similar way like we’re going to do here:

The code:

1
2
<!-- the navigation links -->
3
4
 <ul id="navigation">
5
 <li><a href="#">link 1</a></li>
6
 <li><a href="#">link 2</a></li>
7
 <li><a href="#">link 3</a></li>
8
 <li><a href="#">link 4</a></li>
9
 </ul>

We want the links to float horizontally across the page, so we’ll add the following styles:

First, we want to remove the bullet styling from the list-items, and make them float to the left of each other, and add a bit of space between them.

1
2
#navigation li {
3
 list-style: none;
4
 display: block;
5
 float: left;
6
 margin: 1em;
7
}

Next, we’ll add a bit of text-shadow, remove the link underlines, and add the text color and size.

1
2
#navigation li a {
3
 text-shadow: 0 2px 1px rgba(0,0,0,0.5);
4
 display: block;
5
 text-decoration: none;
6
 color: #f0f0f0;
7
 font-size: 1.6em;
8
 margin: 0 .5em;
9
}

I also like to add a bit of soft animation effects on hover:

1
2
#navigation li a:hover {
3
 margin-top: 2px;
4
}

To add the stars, I’ve placed an HTML entity &#10029; (which looks like this ✭) inside of each link. This is purely decorative, and not needed for the functionality.

At this point, we already have a nice usable navigation link section that we could add into a page. But we’re going to keep going to create a nice ribbon to put these links inside of.

Step 02: The Ribbon Banner

The border-width technique that we’re going to use does require that we add 4 extra elements to the markup. While it’s not ideal to add extraneous elements, in the long-run it’s probably still more efficient than loading up extra graphics, and we’ll keep things as simple as possible.

First, we’ll create a container element around the links. This will allow us to set a width to keep all the banner elements together:

1
2
<div id="navigation_container">
3
4
<!-- the navigation links -->
5
6
 <ul id="navigation">
7
 <li><a href="#">&#10029; link 1</a></li>
8
 <li><a href="#">&#10029; link 2</a></li>
9
 <li><a href="#">&#10029; link 3</a></li>
10
 <li><a href="#">&#10029; link 4</a></li>
11
 </ul>
12
13
<!-- end container -->
14
</div>

We’ll add the following style to set the width and center the container element:

1
2
#navigation_container {
3
 margin: 0 auto;
4
 width: 960px;
5
}

Next, we’ll add the rectangle that will be the body section of the ribbon:

1
2
<div id="navigation_container">
3
4
<!-- the ribbon body -->
5
6
 <div class="rectangle">
7
8
<!-- the navigation links -->
9
10
 <ul id="navigation">
11
 <li><a href="#">link 1</a></li>
12
 <li><a href="#">link 2</a></li>
13
 <li><a href="#">link 3</a></li>
14
 <li><a href="#">link 4</a></li>
15
 </ul>
16
17
<!-- end container -->
18
</div>

We’ll add the following styles to create the ribbon body background. We’re setting a z-index of 500 because the rectangle needs to be stacked on top of the triangles that we’ll create next. I’m adding both -moz-box-shadow and box-shadow to account for Firefox and -webkit/IE9 respectively:

1
2
.rectangle {
3
 background: #e5592e;
4
 height: 62px;
5
 position: relative;
6
 -moz-box-shadow: 0px 0px 4px rgba(0,0,0,0.55);
7
 box-shadow: 0px 0px 4px rgba(0,0,0,0.55);
8
 -webkit-border-radius: 3px;
9
 -moz-border-radius: 3px;
10
 border-radius: 3px;
11
 z-index: 500; /* the stack order: foreground */
12
 margin: 3em 0;
13
}

Next, we’ll add the triangles to the edges of the ribbon:

1
2
<div id="navigation_container">
3
4
<!-- the left side of the fork effect -->
5
 <div class="l-triangle-top"></div>
6
 <div class="l-triangle-bottom"></div>
7
8
<!-- the ribbon body -->
9
10
 <div class="rectangle">
11
12
<!-- the navigation links -->
13
14
 <ul id="navigation">
15
 <li><a href="#">link 1</a></li>
16
 <li><a href="#">link 2</a></li>
17
 <li><a href="#">link 3</a></li>
18
 <li><a href="#">link 4</a></li>
19
 </ul>
20
21
<!-- end the ribbon body -->
22
 </div>
23
24
<!-- the right side of the fork effect -->
25
 <div class="r-triangle-top"></div>
26
 <div class="r-triangle-bottom"></div>
27
28
<!-- end container -->
29
</div>

Finally, we’ll add some border-width magic. The key to this is setting a border-color of transparent for each side of the element except for the bottom (for the top triangles) and top (for the bottom triangles). Then, we set a border-width of 50px. This creates an isosceles triangle, which we will then position behind the main body of the ribbon:

1
2
.l-triangle-top {
3
 border-color: #d9542b transparent transparent;
4
 border-style:solid;
5
 border-width:50px;
6
 height:0px;
7
 width:0px;
8
 position: relative;
9
 float: left;
10
 top: 1px;
11
 left: -50px;
12
}
13
14
.l-triangle-bottom {
15
 border-color: transparent transparent #d9542b;
16
 border-style:solid;
17
 border-width:50px;
18
 height:0px;
19
 width:0px;
20
 position: relative;
21
 float: left;
22
 top: -40px;
23
 left: -150px;
24
}

We’ll do the same for the right side:

1
2
.r-triangle-top {
3
 border-color: #d9542b transparent transparent;
4
 border-style:solid;
5
 border-width:50px;
6
 height:0px;
7
 width:0px;
8
 position: relative;
9
 float: right;
10
 right: -45px;
11
 top: -107px;
12
}
13
14
.r-triangle-bottom {
15
 border-color: transparent transparent #d9542b;
16
 border-style:solid;
17
 border-width:50px;
18
 height:0px;
19
 width:0px;
20
 position: relative;
21
 float: right;
22
 top: -149px;
23
 right: -145px;
24
}

And we’re done! This will render perfectly in Firefox and Webkit browsers. IE is notoriously bad at using these CSS3 properties, so it won't render perfectly there, but we'll do our best to get it pretty close using a couple custom stylesheets.

For IE8 and IE9, we'll add some custom positioning rules through the "ie.css" stylesheet:

1
2
.l-triangle-top {
3
left: 150px;
4
top: 50px;
5
}
6
.l-triangle-bottom {
7
left: 50px;
8
top: -12px;
9
}
10
.r-triangle-top {}
11
.r-triangle-bottom {
12
top: -169px;
13
}

Just to be on the safe side (and since we believe in progressive enhancement), we’ll also add a fix for IE7, which can be placed in either the head section of your page or in a separate IE7 stylesheet. My choice of a fix is to simply hide the triangles in browsers lower than IE8. The browser-width property is supported in IE7, but the spacing will be a bit off. It’s up to you whether you’d like to spend the extra time re-positioning the elements in IE7:

1
2
<!--[if lt ie8]>
3
4
.r-triangle-bottom,
5
.r-triangle-top,
6
.l-triangle-bottom,
7
.l-triangle-top {
8
 display: none;
9
}
10
<![endif]-->

Wrapping It Up

The background images are just for fun - you can add your own and build around this document... or just grab everything above this and drop it into your own design. But, in the interest of being comprehensive, here's the CSS that's adding in those images:

1
2
html{
3
background: #77d5fb url('bottom_bg.jpg') bottom center no-repeat;
4
}
5
6
body{
7
background: transparent url('top_bg.png') top center no-repeat;
8
width: 100%; 
9
height: 100%;
10
margin: 0 0;
11
}

Credits: The images are from iStockPhoto - we can't distribute the bottom island image with the demo, but you can grab it for yourself here.

That's It!

Hope you guys enjoyed this one! Remember that this is a fairly new set of techniques... so if your goal is 100% stability on all browsers known to man, there are more stable ways of accomplishing this using basic images for the background. Leave your comments and questions below ;)

Read More about creating a ribbon or folding effect:

  • Create a 3D Ribbon Wrap-Around Effect (Plus a Free PSD!)

    I thought it might be fun to create a tutorial on the popular 3d Wrap-Around Ribbon effect that has been popping up so much this year. This is a great way to add depth to your designs, and it’s pretty darn easy to complete.

    Visit the Post

  • Quick Tip: Practical CSS Shapes

    A common design technique lately is to create a fold effect, where it appears as if a heading is wrapping behind its container. This is generally achieved through the use of tiny images; however, with CSS, we can mimic this effect quite easily. I’ll show you how in four minutes.

    Visit the Post

Did you find this post useful?

How to Create a Modern Ribbon Banner Navigation Bar with Pure HTML/CSS3 (7)

Sarah Kahn

Sarah Kahn is the UX Engineer at Adzerk where she spends her time doing user experience research and design and frontend code. You can follow her on Twitter @aarahkahak.

Top Articles
Latest Posts
Article information

Author: Ms. Lucile Johns

Last Updated: 02/26/2023

Views: 6237

Rating: 4 / 5 (41 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Ms. Lucile Johns

Birthday: 1999-11-16

Address: Suite 237 56046 Walsh Coves, West Enid, VT 46557

Phone: +59115435987187

Job: Education Supervisor

Hobby: Genealogy, Stone skipping, Skydiving, Nordic skating, Couponing, Coloring, Gardening

Introduction: My name is Ms. Lucile Johns, I am a successful, friendly, friendly, homely, adventurous, handsome, delightful person who loves writing and wants to share my knowledge and understanding with you.