My column header needs to be quite long, but the content of the column is only a few pixels wide, so loads of white space and horizontal scrolling required to see the rest of the content.

Any ideas?

4 Answers 4


You can use SharePoint Designer to edit the AllItems.aspx view on this list. Insert this style inside the content place holder:

<style type= "text/css"> 
  .ms-vh2 {white-space: normal} 

This will override the style for the column headers which is set to white-space: nowrap

  • 5
    If you can't or dont want to use SPD you can also put this in a Content Editor Web Part (CEWP) using the HTML Source option.
    – Ryan
    Jun 6, 2011 at 11:26
  • I've added a few lines of CSS to make it work in 2007/2010 and with non-filterable columns blog.pentalogic.net/2011/06/…
    – Ryan
    Jun 23, 2011 at 17:15

There is also a way to wrap the columns individually using JavaScript by removing the nowrap attribute from the column header.

See Wrap ListViewWebPart Column Headers for more info (shameless link to my blog).


The bast/easy way -> Add JSLink to each view where you want add/remove "white-space".

(function() {
var addClassToField = {};
addClassToField.Templates = {};
// overrideNameField.OnPreRender = RenameColumn;
addClassToField.OnPostRender = AddClass;
addClassToField.Templates.Fields = {
    "Category": {
        "View": FieldToAddClass

function FieldToAddClass(ctx) {
      return "<div class='to-whiteSpace'>" + ctx.CurrentItem["Category"] + "

function AddClass() {
    //white-space: nowrap;
    var headerAddClass = document.querySelector("[name=Category]").parentNode;
    if (headerAddClass.style.whiteSpace != "nowrap") {
        headerAddClass.style.whiteSpace = "nowrap";
    var elementsAddClass = document.getElementsByClassName("to-whiteSpace");
    var elementsAddClassQuant = elementsAddClass.length;
    for (var el = 0; el < elementsAddClassQuant; el++) {
        elementsAddClass[el].parentNode.style.whiteSpace = "nowrap";

easier way:

(function () {
var overrideCtx = {};
overrideCtx.Templates = {};

overrideCtx.OnPostRender = [HeaderWrap];



function HeaderWrap(inCtx) {
   var headers = document.getElementsByTagName("th");
   for (var h = 0; h < headers.length; ++h){
      headers[h].style.whiteSpace = "normal";
   } //for
} //function

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.