A number of queries we received had to do with alignment problems. In some templates, the links, text, widgets and other page elements are aligned to the left. Many bloggers prefer to have widgets in the center of the sidebar or post body. There are a couple of ways to align the page elements within the sidebar or the blog posts. In this tutorial, you will learn how to center align all or selected page elements in your blog.
Header Alignment
If you are looking to center align the Header Title, Description and Header image, look up our other guides - Header Image and Title Alignment (I) for Minima, Denim, Rounders, Herbert, Jellyfish, Harbor and Scribe templates; and Header Image and Title Alignment (II) for the Dots, No. 897, No. 565, Thisaway, Moto, Snapshot, TicTac, Tekka, Sand Dollar and Simple II templates.
Center align all the elements
The general alignment codes are found in the stylesheet. Go to Template -> Edit HTML. If you want the elements in the sidebar to be in the center, try looking for this and insert the alignment code (shown in red):-
#sidebar-wrapper{ text-align:center; } |
|---|
In different templates, the CSS classes are named differently. Hence, if you can't find the above, look for any of these and insert the code:-
#sidebar #sidebar-wrap #side .sidebar |
|---|
Do not save the template. Preview the Template. The text and elements in the sidebar should be in the center and not aligned to the left.

In the same way, if you want the elements in the main post body to be in the center, add the code here:-
#main-wrapper{ text-align:center; } |
|---|
If you don't see this in your template, try inserting the code under any of these or words to that effect and preview the template.
#main #main-wrap .main |
|---|

To center align the Footer elements, the code can be inserted under any of these:-
#footer .footer |
|---|
Center align one element
Suppose you want only one element to be aligned in the center. After you have created that element, be it a picture or widget or text, go to Template -> Edit HTML and scroll to somewhere near the bottom. Look for the widget ID. For example, if we have added a HTML code, a link list and a labels widget in the sidebar, we will see this:-
<div id='sidebar-wrapper'> <b:section class='sidebar' id='sidebar' preferred='yes'> <b:widget id='HTML1' locked='false' title='HTML Code' type='HTML'/> <b:widget id='LinkList1' locked='false' title='Links' type='LinkList'/> <b:widget id='Label1' locked='false' title='Labels' type='Label'/> </b:section> </div> |
|---|
The highlighted text are the widget IDs. Scroll further up the template and insert after a } character the alignment code like this:-
#HTML1{ text-align:center; } |
|---|
Replace the part in green with the relevant ID. This will center align only that particular page element.
DIV alignment tags
The other way to align an element is to insert the DIV alignment tags. Let's say you have created a HTML page element to insert a widget, image links, stat counter, etc. Insert these tags before and after the HTML Code to align that element in the center.
<div style="text-align:center;">HTML Code of widget</div> |
|---|
Center align element in Blog Post
You may center align a picture, code, table, link or text within a blog post. Just block the part you want to put in the center and click the center-align icon in the Post Editor:-

Alternatively, you can switch from the “Compose” mode to the “Edit HTML” mode. Insert these tags and what goes in between will be in the center.
<div style="text-align:center;">TEXT TO BE CENTERED</div> |
|---|
Further reading:-
Style and Position Sidebar Images on image borders and margins in sidebar.
© Tricks for New Bloggers


16 comments:
It's either that or the template e.g., #HTML1{text-align:center;}
We tried all the methods in our Blogger blogs when we wrote this article.
There is already an article on Sidebar Title Background Color and Image. Can take a look.
hi,first of all thanks for the great site !!!
I'm trying to align the Google search bar from the left to the center. in the below example ,,just what line of the code goes replaces " TEXT TO BE CENTERED"?
thanks,,
Richard
style="text-align:center;">TEXT TO BE CENTERED
Hi Richard
Use the DIV alignment tags (see the section in the article) and insert the Google code between the tags.
thanks ... coool post.
how to add code to a blog?? showing it as a text
--
http://goodtoknowit.blogspot.com
Hi Chuck Gates
Use the div alignment tags. For example,
<div align="center">WIDGET CODE</div>
Hi Lily
Try this:-
#BlogArchive1 ul{
text-align:center;
}
Hi Lily
If it is a valid picture file, it should display. If the file size is big, it may take a longer while when the page loads. Try reducing the file size and see if the problem persists.
I need your help! I am a lowly blogger mama and I have been tweaking with your 3 column layout for minima. I have tried to use the coed to have the posts centered with the sidebars on EACH side. And I am still coming up with two sidebars on the right side. I even tried to use the codes that are set for two sidebars on the right thinking they were switched. But to no avail. Can you help me?
www.shoupfam2000.blogspot.com
or shoupfam2000@sbcglobal.net
Thanks, Aja Shoup
really good post,thanks friend
it helped me alot in changing my blog
to your views and suggestion.
Thank you sir
Hi, when I try to center my widget(s) with the div-align code ALL my main wrapper elements are centered, also the text within the posts. I inserted this code before
div id='main-wrapper'
and the closing-/div after the widget list. This works for all.
But how can I make only the widgets be centered, but not the text of the posts?
Thank you for any tip.
Chris
Hey!
To start off, I would like to say that this is a great site! Very helpful indeed.
I also have a question, and this was the most relevant post I could find. I have tested viewing my blog on a 17" computer screen, and as far as I can tell, it fits nicely. However, for widescreen users, my blog is aligned to the left. Is there a way to centralize it?
Thanks!
Thanks for this gr8 info. .........
But i hav some doubt...
my blog has alligned to left side....
i hav tried alot 2 bring it normally but i cant.......plzzz help me.......
i hav added text-align:center;} for main-wrapper and also side-wapper....... but still cant do anything....
my blog is: allstuff4u2.blogspot.com
I recently had my page redesigned, and some sidebar links are centered; some are to the left. I'd like them all to the left. How do I do this?
I just sent a comment...but wanted to let you know that I found out the answer to my own question. Thanks for your blog - it helps a lot!
how to e-mail bizwhiz? if i want to ask a question?
I have a blog http://lwcfamily.blogspot.com. Manage to download image files but the images appear to be in black and white instead of colours on the blog. When click on the images, the new windows appear with bigger image with colours.
Please enlighten me how to solve my problems.
Thank You
I have something to say ...