Styling individual page tabs on Blogger
Changing the appearance of page tabs on Blogger is relatively easy. It can be done via template designer’s built-in menus or using custom CSS. However, the changes will be applied to all tabs.
What if you want to style each tab individually? Let’s say you want to use a different font or color on just a single tab, or add a different background image to each tab, or perhaps you fancy multi-colored tabs like the one on USA Today’s website. Is it possible?
USA Today’s multi-colored navigation tabs
Yes it is possible, with some HTML and CSS tweaks of course. See the demo on our widget showcase blog. Notice that “SEO Tools” tab has a different background color than the rest of the tabs.
This tweak is a two-step process and is limited to Layout templates only (it won’t work on Dynamic templates). Firstly you need to assign an identifier to each tab by editing the Pages gadget template HTML. Once you’ve done that, you can apply a unique style to any tab by referencing it’s identifier in CSS.
Let’s get to work:
1. Assigning a unique identifier(s) to each tab
For you to be able to target each tab individually in CSS, each tab has to have an identifier, and it has to be unique. In our case we will use a classname(s) as the identifier. Here’s how:
Update Nov 2012: Selected tab now keeps your custom tab styling.
- Go to Template > Edit HTML > Proceed, click the Expand Widget Templates checkbox.
- Locate your Pages gadget by finding this line of code:
<b:widget id='PageList1' locked='false' title='Pages' type='PageList'>
- Several lines below that you will find these code:
<li class='selected'><a expr:href='data:link.href'><data:link.title/></a></li> <b:else/> <li expr:class='data:link.title'><a expr:href='data:link.href'><data:link.title/></a></li>
- Replace it with this one:
<li expr:class='data:link.title + " selected"'><a expr:href='data:link.href'><data:link.title/></a></li> <b:else/> <li expr:class='data:link.title'><a expr:href='data:link.href'><data:link.title/></a></li>
What the new code does is adding the title of each tab to the tab’s classname, thus enabling each tab to be referenced by it’s title later.
2. Applying the styling
To style a tab, go to Template > Customize > Advanced > Add CSS and enter a CSS snippet into the custom CSS box. The snippet should be of the following format:
.PageList li.TAB_NAME a {PUT CSS DECLARATIONS HERE}
in which:
- TAB_NAME is the name/title of the tab that you want to style differently. Remember classnames are case sensitive, so make sure you enter the name as you did when you created the pages.
- CSS DECLARATIONS are whatever property:value combinations you like to apply -background color, background image, text color, font etc.. The possibilities are endless.
For example if you want to color your “Contact” tab’s background orange, the code required is this:
.PageList li.Contact a {background-color: #FF8000;}
For a multiple-word tab name, each word will become a classname. So if your tab’s name is “SEO Tools”, you can reference the tab either by using:
- "SEO", like this:
.PageList li.SEO a {background-color: #FF8000;}
- or "Tools", like this:
.PageList li.Tools a {background-color: #FF8000;}
Enjoy!
26 comments to "Styling individual page tabs on Blogger"
nice sharing ,,but not understand about CSS
This is interesting.I use all your tutorials in my Blogs.Great job. Tnx
wow...thx for tutorial <3
i'm new in this and still failed to put background on my tabs...please help me-http://hiqualityarowanahub.blogspot.com/
@Azman
What do you have in mind? Is it:
One background image for all tabs? or
Same background image for each tab? or
Different background image for each tab?
Thanks greenlava for fast reply,i think one background image for all tabs and could you guide me how to make drop down menu ?
(drop down menu ni yang wat kepala nak pecah...aduuuih)and thanks in advance mate
@Azman
Use this CSS code:
.PageList ul {background: url("PUT YOUR IMAGE URL HERE");}
For dropdown menu refer to this tutorial: Installing a multi level CSS dropdown menu
Thanks for this tutorail, From couple of days I was looking for this hack.
Thanks for the help. I have a slight problem I'd love to figure out.I made my index using your tutorial, created a page for it. Edited the tabs, but hate that the index tab is grey until the mouse hovers over it and then the color is there. How do I make the tab just one solid color all the time,so that the home tab and the index tab are the same all the time?
http://tipgarden.blogspot.com
@Tip Garden
Go to Template > Edit HTML > Proceed and find this:
.tabs-inner .widget li.selected a,
.tabs-inner .widget li a:hover {
SOME CODES HERE
}
This the styling code for hover and selected tab.
To enforce the styling to all tabs, replace the code with this:
.tabs-inner .widget li a,
.tabs-inner .widget li.selected a,
.tabs-inner .widget li a:hover {
SOME CODES HERE
}
Hi there! I have been loving your blog tutorials. I am having trouble with this one though and hope you can help. I am unable to locate the code in step 1.3. Here is the snippet that I think is applicable:
<b:widget id='PageList1' locked='false' title='Pages' type='PageList'>
<b:includable id='main'>
<b:if cond='data:title'><h2><data:title/></h2></b:if>
<div class='widget-content'>
<b:if cond='data:mobile'>
<select expr:id='data:widget.instanceId + "_select"'>
<b:loop values='data:links' var='link'>
<b:if cond='data:link.isCurrentPage'>
<option expr:value='data:link.href' selected='selected'><data:link.title/></option>
<b:else/>
<option expr:value='data:link.href'><data:link.title/></option>
</b:if>
</b:loop>
</select>
<span class='pagelist-arrow'>&#9660;</span>
Hope this isn't inappropriate or anything. Thanks in advance :)
@Andrea
That's the code for the mobile version of the tabs. The code you want is just a few lines below that.
Or you can press Crtl+F (to activate search) and enter this code in the search box:
<li expr:class='data:link.title'>
I have a similar question to @Azman's but instead of having the same background image for all, I would like to have a different background image for each tab. What would the HTML code be for that?
Thanks so much!
@Brittney Paulson
1. The HTML code is provided in step 1 of the tutorial.
2. You also need CSS code (as explained in step 2).
Example: The following code will add background image to your "inspirations" tab:
.PageList li.inspirations a {background: url("PUT YOUR IMAGE URL HERE");}
Your blog is awe-inspiring. I have found many new things. Your way of staging is also fascinating. You have elected very incredible topic. I appreciated it.
wow it is working thank you for posting
I really enjoyed this. But how can i edit only a page's html (not the whole blog layout) in blogger?
great! I used that to add som html to that widget!
@Archurst
Just go to Pages and click the Edit link under the page's title.
Hi! Thanks so so much for this tutorial. Huge help! I've gotten the background and font changed for a single tab (for Christmas) and I'm very happy with it. I have one little problem though, when I click on that (Christmas) page the tab changes do not appear. Have I added the css incorrectly or do I need to add code so that the tab will look the same even when I'm on that page?
@The Go2Girl
I've updated the code, check it out. It should fix your problem.
Hello,
I was wondering if you knew how to make this a drop down menu? Thanks. :)
@sherri
See the tutorial here:
http://www.bloggersentral.com/2009/10/installing-multi-level-css-dropdown.html
Thanks! My blog is suddenly looking much better!
lieke-gg.blogspot.com
thanks, it works on my blog. but i have to change it for some other reasons.
Help! ;<
It doesn't work for my home page. ._. What should I put in tab_name?
Post a Comment
We love to hear from you! Leave us a comment.
To ensure proper display, HTML/XML/Javascript need to be escaped first using this escape tool.