Fix width of master page in SharePoint 2010

This SharePoint 2010 master page tutorial explains, how we can fix the width of the master page in SharePoint 2010. Here we will fix the width of the master page to 1000px using CSS in SharePoint 2010.

Rather than modifying directly with out of box master page, my recommendation is to create a new custom master page in SharePoint 2010 and modify on that custom master page in SharePoint 2010.

You can also check how to create Vertical flyout menus in SharePoint 2010.

To fix the master page width, we need to fix in CSS file, and according to SharePoint designer best practices, it is not a good idea to modify in the out of box CSS files. So we can make a custom CSS file and refer the CSS file in the master page. Or in the 2nd approach, we can write inbuilt CSS code in the master page itself.

First Approach – Fix Master Page Width SharePoint 2010

Here we will add a CSS file and put the CSS code inside the file.

Make a css file in the below directory:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\STYLES

And put the below css code there:

<style type=”text/css”>
/*fixed width */
#s4-workspace > div,#s4-bodyContainer > div,body #s4-titlerow > div{
margin:0 auto;
body #s4-mainarea{
/*make main area have background of white and add a border */
border:1px solid #ddd;
/*contain content in all browsers but IE7 */
/*add padding back to title table*/
padding:0 0 0 5px;
/*background color of site*/
#s4-workspace {
background:#efefef /*none*/;
/*body container */
/*fix overhanging tables*/

And save the file.

Now open the SharePoint 2010 site in SharePoint designer 2010.

Then open the master page on which you want to modify and put the below tag:

<SharePoint:CssRegistration runat=”server” Name=”/_layouts/styles/MyCustomCSS.css” After=”corev4.css”/>

2nd Approach – Add CSS directly on the Master Page

In the 2nd approach, Open the SharePoint 2010 site using SharePoint designer 2010, And then Open the master page where you want to modify.

Search for </head>

And before that paste the .CSS code from the above and save and publish the master page in SharePoint 2010.

You may like following SharePoint master page tutorials:

After that when you open the SharePoint 2010 site, the website will be fixed size.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.