SharePoint Tip – How To Set Word Wrapping on List Column Headers

I have a list in SharePoint that has numbers of columns with very long headers and I’d like to wrap these long headers so that I can have more columns shown on the screen. By default, I couldn’t. But with a little nice trick, I can.

The reason why I couldn’t by default because the default CSS style sheet the list uses has white-space: nowrap in place that prevents anything from wrapping. If we want the header wrapped we need to find a way to overwrite the white-space style with normal instead.

So here is how I did it, inspired by Ryan here.

Go to my list, select Site Actions and choose Edit Page.

Sharepoint - edit page

Click Add a web part, then select Media and Content and Content Editor, and click Add to add the selected web part to the current page.

Sharepoint - add webpart

Select the newly added web part, and select HTML → Edit HTML Source from the ribbon.

SharePoint - edit HTML source

And paste in the following style codes.

<style type="text/css">
.ms-vh, .ms-vh2-nofilter, .ms-vh2-nograd, .ms-vh2, .ms-vb, .ms-vb2
{
white-space: normal;
text-align:center; 
vertical-align:text-bottom;
color:red;
}
</style>​

Click OK to save the change. Refresh the page and done.

It’s a very nice and useful trick in SharePoint because, with this added style web part, I can actually customize the style sheet to have the list displaying in a way I really wanted.

You can also accomplish the same with SharePoint Designer if you have one handy.

5 thoughts on “SharePoint Tip – How To Set Word Wrapping on List Column Headers

    1. Yes, that’s because you added the web part for CSS style on the page. I believe you can click inside the list to have the items & lists menu to show up again.

Leave a Reply

Your email address will not be published. Required fields are marked *