There are several different ways to achieve this effect, and it really depends on your preference. As you correctly postulated, you need to think of it as three different parts. Thus, the easiest way would be to split it into 3 different images.
The solution also depends on how your HTML markup looks. For example, if you only have:
<a class="tab" href="#">My Tab</a>
Then you have only one element that you can create to do this (which makes it much harder).
However, if you have a wrapping element around the tab:
<li class="tab"><a href="#">My Tab</a></li>
Then you can use the LI element to achieve the desired result.
Single element
In my first example, you had only one anchor element. After examining the image that you want to use for the tab, I see that it has some bevel and is not a simple flat color or a flat color with a simple border. This means that we will not be able to achieve this effect using direct CSS, so we need CSS to split the image.
You have two options.
Option 1
Divide the image into two images on the left and right, dividing it in the center down. Then, in the image editing application, stretch your canvas to the right, say 200 pixels (or what do you think the maximum tab width will ever be). Finally, select the farthest right edge (this should be in the middle of the tab) and stretch it horizontally to the right border.
What you need in the end is the slanted left side, and then the average area is β200 pixelsβ.
Now you have two images, which we will call tab-left-side.png and tab-right-side.png . With these two images, you can achieve the influence of a tab with the following CSS:
.tab { background: url(tab-left-side.png) no-repeat 0 0; overflow: hidden; padding-left: 10px; } .tab:after { content: ' '; overflow: hidden; width: 10px; background: url(tab-right-side.png) no-repeat 0 0; }
Option 2
This option requires splitting the image into three images. You will have tab-left-side.png , tab-middle.png and tab-right-side.png . As you can guess, you should split the image into them accordingly.
Now you can use CSS:
.tab { background: url(../images/tab-middle.png) repeat-x 0 0; overflow: hidden; color: white; float: left; margin: 0 10px; } .tab:after { content: '.'; overflow: hidden; text-indent: -999px; float: right; width: 17px; background: url(../images/tab-right-side.png) no-repeat 0 0; } .tab:before { content: '.'; text-indent: -999px; overflow: hidden; float: left; background: url(../images/tab-left-side.png) no-repeat 0 0; width: 17px; }
Double element
A double element is performed exactly the same as Option 1 of the Single Element example, except that you do not need to use pseudo-class selectors. If you are writing code that should support older browsers that do not support pseudo-class selectors (or at least :before and :after ), then this is your only option.
Again, you split the two images up into tab-left-side.png and tab-right-side.png .
Then your CSS:
LI.tab { background: url(tab-left-side.png) no-repeat 0 0; overflow: hidden; padding-left: 10px; } LI.tab A { content: ' '; overflow: hidden; width: 10px; background: url(tab-right-side.png) no-repeat 0 0; }
This is almost the same CSS as in the Option 1 example, except that we changed the selector.