Modify the lengths of List Form Fields

Hi again, John here with a post that I hope will help out a lot of people.

The scenario is simple: You have just used SharePoint Designer to insert a Data View of some list. You have formatted the fields to be SharePoint:FormField controls, and now you want to change the size of those controls.

Why is this so hard? Well, the controls are rendered from the server (as are all controls) and so the markup (or HTML) used to make them display in the browser cannot be directly manipulated on the SPD design surface. What we need to do is determine the class SharePoint uses to render the size of the controls, and then override it via CSS.

For this demo, we'll use the default Title field from the default Announcements list. These steps also assume that you know how to create new pages and insert views on them.

  1. Make sure you have at least one announcement in your Announcements list
  2. Open your site in SharePoint Designer
  3. Create a new page based on the Master page
  4. Click on Task Panes > Data Source Library
  5. Click on the Announcements list and click Show Data
  6. Select the Title data value
  7. Click Insert Selected Fields as > Single Item Form
  8. Save the page and press F12 to Preview in Browser
  9. Right click the page in the browser and click View Source
  10. Select All > Copy
  11. Create another new page in SPD and Paste all of the content into this new page's Code View
  12. Click back into Design View
  13. Select the Textbox control for the Title field

At this point you can see that the class on this field is called ms-long. This is the class we need to override. So for other controls, we just want to follow the same steps above. By getting the server generated HTML from the browser in step 10, we are able to use all of SPD's tools to understand the HTML. I do this a lot when dealing with the customization of server controls.

Now we just need to add a <style> block inside our first page that says something like below, then save the page.:


This will make the textboxes on this page 100 pixels wide.

If you want to know more about CSS in general, check out the information on the Microsoft SPD Site. If you want to know more about Core.CSS in SharePoint, check out this Style Guide.

Good luck!
-John Jansen
Test Lead, SharePoint Designer

Comments (25)

  1. Him says:

    Great Post. My requirement is that I need to create a custom column of type ‘choice’ for a list   but the check boxes should appear in horizontal pattern rather than the default vertical pattern. Any Suggestions?

  2. spdblog says:

    Hi Him,

    Unfortunately, I don’t think so using SharePoint Designer. If you are a server admin, you can create a custom control rendering for that.

    The control renders as a table, and each check box is in its own TR. Unfortunately, the TRs and TDs do not have IDs on them, so even if I knew some fancy CSS that would trick a TR into laying out horizontally, there is no way to actually identify which cells to apply that CSS to.


  3. Kan says:


    I followed your post to modify the width of a text box (ms-long), a people picker(ms-inputuserfield) and a multi-line rich text box (ms-long). The text box transformed as expected, but the people picker and a multi-line rich text box does not seem to change at all. Any advice?


  4. sprocket says:

    This worked well – but:

    I have a bunch of fields I want to be different lengths. One field is a 3 digit number, the next a name of up to 30 characters and so on. The server tags them all as .ms-long however, so the above solution only allows me to change them all to the same length – either too long for numbers or too short for the names. Is there any way around that?

  5. jaxstate says:

    Putting something like the javascript code below does a fairly decent job of acheving variable length form fields..


    var inputs = document.getElementsByTagName("input");

    var width = 0;

    for(var i=0;i<inputs.length;i++)


    if(inputs[i].className == "ms-long")


    width = (inputs[i].maxLength * 11) + 2;

    if(inputs[i].maxLength != 255)//&& width < 390)  

    inputs[i].style.width = width + "px";




  6. Jay says:

    Hi Jax,

    I pasted your code in the this tag-<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server"> of the newform.aspx page but i don’t know how to use this javascript to make field lenghts of variable sizes..could you please direct?

    many thanks


  7. jaxstate says:

    Create a new Content Editor Web Part on the NewForm.aspx page using the "toolpaneview hack" described here –

    Place the new Content Editor Web Part at the bottom of the page an paste the script into it.

    You will then be able to set your field widths based on the maximum number of characters you allowed for the field. Also, allowing 255 characters for a field effectively disables the script for that field… Uncomment the "&& width < 390" part to specify a maximum width for your field..

  8. jiminy says:

    Just a quick note, the class to override the width for a people picker is ms-usereditor, not ms-inputuserfield

  9. jaxstate says:

    The JavaScript I posted earlier calculates the field width based on how many capital "W"s would fit into the rendered textbox – and it works great as long as the user enters all capital Ws but often I need the user to enter a phone number. The following JavaScript code allows me to specify the exact length I would like to use for the field in pixels by entering the length anywhere in the field description using the format $<length>px

    The javascript first loops through the collection of input fields looking for fields with the style "ms-long". It then looks at the innerText of the parent TD element (field description) of those fields to find a $ sign followed by some numbers followed by ‘px’. It then uses this info to set the field width and finally replaces the innerText to prevent the info from displaying to the user..

       var inputs = document.getElementsByTagName("input");

       var width = 0;

       for(var i=0;i<inputs.length;i++)


           if(inputs[i].className == "ms-long")


               var intxt = inputs[i].parentNode.parentNode.innerText;

               var match = /$([0-9]*px)/i.exec(intxt);



                   inputs[i].style.width = match[1];

                   inputs[i].parentNode.parentNode.innerHTML = inputs[i].parentNode.parentNode.innerHTML.replace(match[0],"");




  10. Charles says:

    Hey Kan,

    Did you get an answer to your question?  I still can’t get the width of a RTF box to change.  The plain text boxes modify just fine.


  11. share4ever says:


    very useful post: thx

    I have a question about resize of sharepointcomposant " list with multiple choise" ,

    this composant dont have a style classe .

    how can i do for resize the two list ?


  12. Ravi Vajaria says:

    to know which css class is being used, IE Developer Toolbar is a great tool! I just wanted to increase the width of controls in new, edit and disp forms of a list, I just overrode .ms-long (new, edit) and .ms-formbody (disp form)!

  13. Kosher says:

    I can’t believe this is the only way to change the form field values.  Didn’t you guys think that users might want to change the field sizes and edit the visual layout?  Was it too hard to add an additional property for the visual properties of each field?  So many issues like this.

  14. Zol says:

    I agree, we are getting egg on our faces almost daily due to small silly items being so difficult to manipulate. Clients don’t care what or where you need to change. They simply want the changes.

  15. Devon says:

    I really need to edit the width of the RTF or multi-line text box, etc. so far no one has answered this question. Please help me make this easier on my users.

  16. Nick says:

    I have the same problem as KAN, :

    I followed your post to modify the width of a text box (ms-long), a people picker(ms-inputuserfield) and a multi-line rich text box (ms-long). The text box transformed as expected, but the people picker and a multi-line rich text box does not seem to change at all. Any advice?

    Can anybody tell me the solution to this ??

  17. JL says:

    For the Rich Text Fields, the class is either ms-rtelong or ms-rtelonger (or both).  I’m not sure what determines which class applies…

  18. knijn says:

    Hi, I also changed the ms-rtelong and ms-long to eg 800, but when I enter a lot of text in it, it is ok when you look at it via the new or edit item, but when you just view the item, the text is shortened (wrapped) after some words, so the width is not kept in the dispform css ???

  19. knijn says:

    I added width:800px to ms-formbody now and apparently this works fine

  20. ThiNG says:


    Thanks for those class names.

    How the heck did you find the names? I searched the HTML and there is nothing called ms-rtelong but it definitley is the correct CSS class. It updated the fields as soon as I changed it.

    This had been driving me nuts for so long. The editor box was always shorter than the toolbar in my custom CSS…sigh…

  21. FolcoTook says:

    To change the width of the people picker, I used .ms-usereditor.

  22. Chanda says:

    I’ve been able to use the javascript provided by jaxstate to set the length of a field with the class ms-long, however I am unable to get the same to work for a lookup field (ms-lookuptypeintextbox).  I’m using the IE developer toolbar to find the class but when I modify the script to check for that value it doesn’t work.  Any ideas?

  23. Lindy Gibbons says:

    Excellent information – huge help !!

  24. Shiba1000 says:

    I’m trying to increase the width of the lefthand box inside an Add / Remove Formfield

    [  ] add>          [   ]

    [  ] <remove    [   ]

    (want this side to be wider)

    Anyone know how to do that in SP designer?

Skip to main content