I am trying to center align the announcements web part on my Sharepoint 2010 page, everything I try to do just centers the text, not the web part. Is it even possible to change the alignment from left or is it a limitation of SharePoint?


2 Answers 2


This is usually what I do for most of my webpart, you might have to adjust the selector for the web part you have but it should work right off the bat.

.s4-wpTopTable {
margin-left: auto;
margin-right: auto;

Just copy the following code into a CEWP on your page.

  • Works perfectly, thankyou very much Commented Mar 23, 2016 at 15:18
  • Can you elaborate on the steps to 'copy code into a CEWP' please?
    – jakc
    Commented Oct 25, 2018 at 15:05

@Simon - I don't have enough reputation to comment, but "copy code into CEWP" would mean copying the code into a Content Editor Web Part. This web part can be added to the page just like any other web part, via "Edit Page" (in the Page ribbon), then click one of the "Add Web Part" links on the page or use the "Web Part" button on the Insert ribbon at the top. Choose "Content Editor Web Part" from the list (in the Media/Content category). Then, select the web part, then click the "Edit Source" button in the ribbon, and finally, paste in the code. You can optionally set the web part to hidden as well in the web part's properties. Apply the changes to the web part, then save the page and you should be all set.

Alternatively, you could accomplish the same by editing the page in SharePoint Designer and adding the code manually. CEWPs sometimes work well and sometimes not in my experience; it depends what you want to do. For something simple like adding a style block it should work alright.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.